Android Studio 可以使用 OpenJDK 还是在 Linux 上需要 Oracle JDK?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35741439/
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-09-19 03:10:51  来源:igfitidea点击:

Can Android Studio use OpenJDK or does it require Oracle JDK on Linux?

androidlinuxoracleandroid-studioopenjdk

提问by Grant Rostig

Can Android Studio use OpenJDK 1.8 or does it require Oracle JDK on Linux? It would be easier to use OpenJDK because it comes installed on Fedora.

Android Studio 可以使用 OpenJDK 1.8 还是在 Linux 上需要 Oracle JDK?使用 OpenJDK 会更容易,因为它安装在 Fedora 上。

I'm running 64 bit Fedora-23 linux with Android Studio 1.5.1.build AI-141.2456560 on an Intel Haswell i7 chip.

我在 Intel Haswell i7 芯片上运行带有 Android Studio 1.5.1.build AI-141.2456560 的 64 位 Fedora-23 linux。

$ java -version
openjdk version "1.8.0_72"
OpenJDK Runtime Environment (build 1.8.0_72-b15)
OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)

$ ./java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

$ uname -a
Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ more build.txt 
AI-141.2456560

回答by Grant Rostig

No, just as the android documentations says, Oracle JDK is required. I got a "null pointer exception" on render on when running a simple build of an empty project with openJDK. This error probably came from the IDE, not the build of the APK file.

不,正如 android 文档所说,需要 Oracle JDK。使用 openJDK 运行空项目的简单构建时,渲染时出现“空指针异常”。此错误可能来自 IDE,而不是 APK 文件的构建。

After running studio with Oracle's JDK, it all worked properly with no change to the code.

使用 Oracle 的 JDK 运行 studio 后,一切正常,代码没有更改。

Actually it gets more complicated than that because, I have both versions on my system. Oracle JDK is used to launch the studio.sh file, but inside studio I still have the OpenJDK specified under "Project Structure> JDK" as:

实际上它比这更复杂,因为我的系统上有两个版本。Oracle JDK用于启动studio.sh文件,但在studio内部,我仍然在“项目结构> JDK”下指定了OpenJDK:

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.72-4.b15.fc23.x86_64

I'll report back if this hybrid situation fails.

如果这种混合情况失败,我会报告。

回答by bwt

I am using Android Studio since version 1.0 (currently 2.0 beta) on Fedora 64 bit (currently 23) and OpenJDK. It used to display a warning saying something like "OpenJDK is not supported, do not open bug reports if something goes wrong", I don't know if it it still does (I may have clicked on "Don't show this again").

我在 Fedora 64 位(当前为 23)和 OpenJDK 上从 1.0 版(当前为 2.0 测试版)开始使用 Android Studio。它曾经显示一个警告,说“不支持 OpenJDK,如果出现问题,请不要打开错误报告”,我不知道它是否仍然存在(我可能点击了“不再显示这个”) )。

There was also a warning about libinput but I think it is not related to OpenJDK.

还有一个关于 libinput 的警告,但我认为它与 OpenJDK 无关。

Anyway in my case it works quite well, as far as I can remember I did not have to use special tricks. Obviously your mileage may vary.

无论如何,在我的情况下它工作得很好,据我所知,我不必使用特殊的技巧。显然,您的里程可能会有所不同。