简体   繁体   English

Android Studio无法找到我的JDK

[英]Android Studio cannot find my JDK

I have Android Studio installed on my Linux Mint 15 machine and I am trying to use it with LibGDX. 我在我的Linux Mint 15机器上安装了Android Studio,我正在尝试将它与LibGDX一起使用。 In LibGDX I have created a project with intelliJ selected in the advanced creation menu. 在LibGDX中,我创建了一个在高级创建菜单中选择了intelliJ的项目。 In Android Studio, when I go to Configure>Project Defaults>Project Structure, The JDK Location is blank and it says at the bottom "Please choose a valid JDK directory." 在Android Studio中,当我转到配置>项目默认值>项目结构时,JDK位置为空白,并在底部显示“请选择有效的JDK目录”。 I have OpenJDK installed, and when I run java -version in a terminal it returns: 我安装了OpenJDK,当我在终端中运行java -version时它会返回:

"java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)"

When I type javac -version in a terminal that returns: 当我在返回的终端中键入javac -version时:

"javac 1.7.0_80"

When I open the project I created in LibGDX in Android Studio it says at the bottom: 当我打开我在Android Studio的LibGDX中创建的项目时,它在底部说:

"Error: The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: /home/myname/Android/Sdk/bin/java"

I have added the JAVA_HOME environment variable to my profile file and have even tried pasting the java executable in said "/home/myname/Android/Sdk/bin/java" folder but it still returns the same error. 我已将JAVA_HOME环境变量添加到我的配置文件中,甚至尝试在所述"/home/myname/Android/Sdk/bin/java"文件夹中粘贴java可执行文件,但它仍然返回相同的错误。 If anyone knows a fix please let me know! 如果有人知道修复,请告诉我! Thank you. 谢谢。

EDIT: My issue has been resolved! 编辑:我的问题已经解决了! Thank you for your help. 谢谢您的帮助。

我这样解决:在全局gradle设置中,使用本地gradle分配。

A little old but on my Windows 10 Machine I got the problem resolved after pointing to the 32Bit Version of the JDK. 有点旧但在我的Windows 10机器上,我在指向JDK的32位版本后解决了问题。 By default the Android Studio took the 64Bit one which didn't work for me. 默认情况下,Android Studio使用了64Bit,这对我来说不起作用。

So simply change the path to the 32Bit Version or install a 64Bit Version of the Android Studio if there is one, I did not check on that. 因此,只需更改32Bit版本的路径或安装64位版本的Android Studio,如果有的话,我没有检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM