Android studio错误运行项目后

时间:2014-02-21 04:36:40

标签: android android-studio android-support-library

我在尝试从android studio

运行我的应用程序时遇到以下错误

Execution failed for task ':app:compileDebugJava'. Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory

在互联网上搜索后,我找到了一些像这样的解决方案

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45/ 

所以我在android studio dirctory的终端中给出了这个命令但是它没有训练它再次显示相同的错误。

7 个答案:

答案 0 :(得分:71)

更新我的Gradle构建版本对我有用。

旧:

classpath 'com.android.tools.build:gradle:1.0.0'

新:

classpath 'com.android.tools.build:gradle:2.2.3'

编辑:由于此答案仍在频繁使用,请注意Gradle 2.2.3可能可以替换为任何较新版本的Gradle。这个版本恰好是我最初回答问题时使用的版本。

答案 1 :(得分:50)

在你的android-studio中  在File-> Other Settings-> Default Project Structure-> SDKs中找到它。然后我改变了JDK主路径。

答案 2 :(得分:5)

要在Andriod Studio 2.3.1中修复此错误,我必须转到File > Project Structure Ctrl + Alt + Shift + S 然后转到已经为我打开的SDK位置,然后取消选中“使用嵌入式JDK”并指向我安装的版本所在的位置。

答案 3 :(得分:2)

要在Andriod Studio 2.3.1中修复此错误,我必须转到文件>项目结构或 Ctrl + Alt + Shift + S 然后转到已经为我打开的SDK位置然后取消选中“使用嵌入式JDK”并指向我安装的版本所在的位置。

*

  

上述帖子经过长时间的搜索后确实解决了我的问题。

*

答案 4 :(得分:1)

在android studio中

窗口 - >偏好 - > Java - >安装JRE并选择JDK主路径

或者请按照link在Linux机器中设置JAVA_HOME

答案 5 :(得分:1)

在你的android-studio中,在File-> Other Settings-> Default Project Structure-> SDKs中找到它。
然后使用JDK LOCATION选中Installed JDK Location和APPLY IT。

答案 6 :(得分:0)

当我第一次尝试打开旧项目时,我遇到了很多这个问题。看来我只需要更新build.gradle下的类路径:

在我的情况下,旧版本是:
classpath 'com.android.tools.build:gradle:1.3.0'
我更新到:
classpath 'com.android.tools.build:gradle:2.3.2'

同步gradle,它应该编译。