运行项目后Android studio报错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21925388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:18:32  来源:igfitidea点击:

Android studio error After run the project

androidandroid-studioandroid-support-library

提问by Hari Haran

I am getting following error while trying to run my app from android studio

尝试从 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.

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.

After searching on internet, I found some solution like this

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

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

so i gave this command in terminal from android studio dirctory but its not workout it show the same error again.

所以我在 android studio 目录中的终端中给出了这个命令,但它不是锻炼它再次显示相同的错误。

回答by eatcrayons

Updating my Gradle build version did the trick for me.

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

Old:

老的:

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

New:

新的:

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

Edit: Since this answer is still being used frequently, note that Gradle 2.2.3 can probably be substituted with any newer version of Gradle. This version just happened to be the version I was using when I originally answered the question.

编辑:由于这个答案仍然经常被使用,请注意 Gradle 2.2.3 可能会被任何较新版本的 Gradle 替换。这个版本恰好是我最初回答问题时使用的版本。

回答by Hari Haran

In your android-studio find it in File->Other Settings->Default Project Structure->SDKs. Then i changed JDK home path.

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

回答by Brockenstein

To fix this error in Andriod Studio 2.3.1 I had to go to File > Project Structureor Ctrl+Alt+Shift+Sthen go to SDK Location which was already open for me and then uncheck "Use embedded JDK" and point to where my installed version was.

要修复的Andriod 2.3.1工作室这个错误我不得不去File > Project StructureCtrl+ Alt+ Shift+S然后去SDK的位置这是已经为我敞开,然后取消选择“使用嵌入的JDK”并指向我安装的版本了。

回答by YASAM FAMILY

To fix this error in Andriod Studio 2.3.1 I had to go to File > Project Structure or Ctrl+Alt+Shift+Sthen go to SDK Location which was already open for me and then uncheck "Use embedded JDK" and point to where my installed version was.

要解决此错误的Andriod 2.3.1工作室我不得不去文件>项目结构或Ctrl+ Alt+ Shift+S然后去SDK的位置这是已经为我敞开,然后取消选择“使用嵌入的JDK”并指向我安装的版本是.

*

*

The mentioned post really solved my problem after long searching.

经过长时间的搜索,提到的帖子确实解决了我的问题。

*

*

回答by Sasikumar Murugesan

In the android studio

在安卓工作室

Window -> preferences -> Java -> Installed JREs and select your JDK home path

窗口 -> 首选项 -> Java -> 已安装的 JRE 并选择您的 JDK 主路径

or else please follow the linkto set JAVA_HOME in linux machines

否则请按照链接在 linux 机器中设置 JAVA_HOME

回答by Amit Walke

In your android-studio find it in File->Other Settings->Default Project Structure->SDKs.
Then Check with JDK LOCATION select Installed JDK Location and APPLY IT.

在您的 android-studio 中,在 File->Other Settings->Default Project Structure->SDKs 中找到它。
然后检查 JDK LOCATION 选择 Installed JDK Location 并应用它。

回答by Toby

I have this problem a lot when I try to open older projects for the first time. It seems that I just need to update the classpath under build.gradle:

当我第一次尝试打开旧项目时,我经常遇到这个问题。看来我只需要更新build.gradle下的classpath:

In my case the old version was:
classpath 'com.android.tools.build:gradle:1.3.0'
and I updated to:
classpath 'com.android.tools.build:gradle:2.3.2'

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

Sync the gradle and it should compile.

同步gradle,它应该可以编译。