我是最新的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 :(得分:0)
我现在唯一可以画的是奇怪你的班级extends
Activity
,因为其中一些电话无法“解决”,可能意味着他们不知道他们应该来自{{ 1}}例如。另外context.findViewById()
上也有一个错误行,所以看起来它可能认为你不需要创建覆盖。确保你也@Override
import
(这看起来像一个活动,因为它调用onCreate()而不是onCreateView()这是片段。)和android.app.Activity
。