Java Android Studio:“Gradle 同步失败:无法从选定的 JDK 运行 JVM。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52584625/
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
Android Studio: "Gradle sync failed: Could not run JVM from the selected JDK."
提问by Diddy Cool
Ever since installing Android Studio 3.2, I haven't been able to run Java, I have tried jdk-8u181-windows-x64
, jdk-10.0.2_windows-x64_bin
, jdk-11_windows-x64_bin
, setting PATH
and reinstalling everything umpteen times, the result is the same - no "java" appears and the error message is: -
自从安装Android Studio中3.2,我一直无法运行Java,我都试过jdk-8u181-windows-x64
,jdk-10.0.2_windows-x64_bin
,jdk-11_windows-x64_bin
,设置PATH
并重新安装一切许许多多次,结果是一样的-没有“Java”的出现和错误消息是: -
Gradle sync failed: Could not run JVM from the selected JDK. Please ensure JDK installation is valid and compatible with the current OS (Windows 8.1 6.3, amd64). If you are using embedded JDK, please make sure to download Android Studio bundle compatible with the current OS. For example, for x86 systems please choose a 32 bits download option. (369 ms)
Gradle 同步失败:无法从选定的 JDK 运行 JVM。请确保 JDK 安装有效并与当前操作系统(Windows 8.1 6.3、amd64)兼容。如果您使用嵌入式 JDK,请确保下载与当前操作系统兼容的 Android Studio 包。例如,对于 x86 系统,请选择 32 位下载选项。(369 毫秒)
Notes: I used to be able to open the java folder but after playing with it too much, something went wrong, so, I decided to start afresh... and I am dead ever since.
备注:我曾经可以打开java文件夹,但玩了太多,出了点问题,所以,我决定重新开始……从那以后我就死了。
Is Studio 3.2 flawed? Not compatible with Java at all? Or am I missing something? is there a older Android Studio I can test? Thanks for any help you may provide.
Studio 3.2 有缺陷吗?根本不兼容Java?或者我错过了什么?有我可以测试的旧版 Android Studio 吗?感谢您提供的任何帮助。
回答by Víctor López
Try setting your SDK location. I had the same problem with Android Studio 3.2 (but I also switched to openjdk, so that could be the source of my problem). Anyway, after pointing SDK location to the root of my JDK it worked like a charm. To change SDK location click on the Android project Window and then press F4. In the new Window choose SDK location and set it to point to the root of your JDK.
尝试设置您的 SDK 位置。我在 Android Studio 3.2 上遇到了同样的问题(但我也切换到了 openjdk,所以这可能是我的问题的根源)。无论如何,在将 SDK 位置指向我的 JDK 的根目录之后,它就像一个魅力。要更改 SDK 位置,请单击 Android 项目窗口,然后按 F4。在新窗口中选择 SDK 位置并将其设置为指向 JDK 的根目录。
回答by Olaniyi Philip Ojeyinka
i got mine working by setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181\bin my jdk folder
我通过将 JAVA_HOME 环境变量设置为 C:\Program Files\Java\jdk1.8.0_181\bin 我的 jdk 文件夹来开始工作
回答by Carmen
In my case, the following solved it:
就我而言,以下解决了它:
File->Other settings->Default Project Structure...
文件->其他设置->默认项目结构...
In "JDK Location", I previously had the oracle jdk selected. To fix this issue, I instead checked "Use embedded JDK (recommended)"
在“JDK 位置”中,我之前选择了 oracle jdk。为了解决这个问题,我改为选中“使用嵌入式 JDK(推荐)”
回答by coding
In my case, the following solved it:
就我而言,以下解决了它:
File->Other settings->Default Project Structure...
文件->其他设置->默认项目结构...
setting the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.8.0_181
将 JAVA_HOME 环境变量设置为 C:\Program Files\Java\jdk1.8.0_181
my JDK Source File
我的 JDK 源文件
回答by user11588425
Solved YES Other Settings ---> Default Project Structure ---> Uncheck Embedded jdk ( Write Your Own jdk Location )
解决了 YES Other Settings ---> Default Project Structure ---> Uncheck Embedded jdk (Write Your Own jdk Location)