2016-05-23 173 views
0

我是最新的Android Studio 2.1.1,我試圖製作一個簡單的計算器。但是,由於某種原因,我得到了這個非常奇怪的問題,有許多方法無法解決。爲了確保我沒有搞砸任何重要的文件,我複製了所有代碼並將其粘貼到新的新項目中。但我仍然有錯誤,也許我需要重新安裝Android Studio? what my project looks like錯誤:無法解析的方法

,這裏是我的消息:

Information:Gradle tasks [:app:assembleDebug] 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:mergeDebugShaders UP-TO-DATE 
:app:compileDebugShaders UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources UP-TO-DATE 
:app:generateDebugSources UP-TO-DATE 
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE 
:app:compileDebugJavaWithJavac 
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). 
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java 
:app:compileDebugJavaWithJavac FAILED 
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. 
> Compilation failed; see the compiler error output for details. 
Information:BUILD FAILED 
Information:Total time: 1.612 secs 
Information:30 errors 
Information:0 warnings 
Information:See complete output in console 

和我gradle這個控制檯:

Executing tasks: [:app:assembleDebug] 
Configuration on demand is an incubating feature. 
Incremental java compilation is an incubating feature. 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:mergeDebugShaders UP-TO-DATE 
:app:compileDebugShaders UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources UP-TO-DATE 
:app:generateDebugSources UP-TO-DATE 
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE 
:app:compileDebugJavaWithJavac 
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). 

C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:26: error: cannot find symbol 
     super.onCreate(savedInstanceState); 
      ^
    symbol: method onCreate(Bundle) 
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:27: error: cannot find symbol 
     setContentView(R.layout.activity_main); 
     ^
    symbol: method setContentView(int) 
    location: class MainActivity 
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:24: error: method does not override or implement a method from a supertype 
    @Override 
    ^
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:32: error: cannot find symbol 
     one = (Button) findViewById(R.id.one); 
        ^
    symbol: method findViewById(int) 
    location: class MainActivity 
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:33: error: cannot find symbol 
     two = (Button) findViewById(R.id.two); 
        ^

         ^
    symbol: method findViewById(int) 
    location: class MainActivity 
C:\Users\Home\AndroidStudioProjects\CalcuterTest\app\src\main\java\com\kingjulian\www\calcutertest\MainActivity.java:51: error: cannot find symbol 
     answer = (TextView) findViewById(R.id.answer); 
          ^
    symbol: method findViewById(int) 
    location: class MainActivity 
23 errors 

:app:compileDebugJavaWithJavac FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:compileDebugJavaWithJavac'. 
> Compilation failed; see the compiler error output for details. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 1.411 secs 

回答

0

我當時可以得出的唯一的事情是奇蹟呢你extendsActivity,因爲其中一些電話不能被「解決」並且可能意味着他們不知道他們應該來自例如context.findViewById()。另外@Override也有一個錯誤行,所以它似乎可能認爲你不需要創建一個覆蓋。確保你也importandroid.app.Activity(這看起來像一個活動,因爲它調用onCreate()而不是onCreateView()這是片段。)和android.os.Bundle以及。

+0

就是這樣!謝謝! – Julian5234

+0

很高興你的問題得到解決。 :) –