Android Studio给出了关于JDK位置的警告



Android Studio 3.6在Gradle同步完成后显示以下警告:

15:51   Gradle sync finished in 27 s 97 ms
15:51   Android Studio is using the following JDK location when running Gradle:
/home/azabost/java/jdk8u252-b09
Using different JDK locations on different processes might cause Gradle to
spawn multiple daemons, for example, by executing Gradle tasks from a terminal
while using Android Studio.

我不知道我为什么看到它,也不知道它是否有意义。项目建设正常,没有任何问题。我在一个全新的Ubuntu系统上,在那里我安装了AdoptOpenJDK到/home/azabost/java/jdk8u252-b09,并安装了AndroidStudio 3.6到/home/azabost/bin/android-studio-3.6。我导出了几个与JDK相关的路径:JAVA_HOMEJDK_HOMESTUDIO_JDK,以确保Android Studio能够正确地获取我的JDK。以下是几个命令的输出,显示JDK的正确位置:

$ which java
/home/azabost/java/jdk8u252-b09/bin/java
$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.252-b09, mixed mode)
$ export | grep java
JAVA_HOME=/home/azabost/java/jdk8u252-b09
JDK_HOME=/home/azabost/java/jdk8u252-b09
PATH=/home/azabost/bin:/home/azabost/java/jdk8u252-b09/bin:/home/azabost/bin/android-sdk/platform-tools:/home/azabost/bin/android-sdk/emulator:/home/azabost/bin/android-sdk/cmdline-tools/latest/bin:/home/azabost/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
STUDIO_JDK=/home/azabost/java/jdk8u252-b09
./gradlew --version
------------------------------------------------------------
Gradle 6.3
------------------------------------------------------------
Build time:   2020-03-24 19:52:07 UTC
Revision:     bacd40b727b0130eeac8855ae3f9fd9a0b207c60
Kotlin:       1.3.70
Groovy:       2.5.10
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_252 (AdoptOpenJDK 25.252-b09)
OS:           Linux 5.4.0-28-generic amd64

当我在AndroidStudio中打开"项目结构"对话框时,我可以看到正确的JDK已经设置好了。但当我点击下拉菜单选择不同的JDK时,我会看到一些奇怪的东西。有两种选择:

  1. 嵌入式JDK:/home/azabost/bin/android-studio-3.6/jre
  2. JAVA_HOME:/HOME/azabost/bin/android-studio-3.6/jre

因此嵌入式JDK被列了两次,其中包括一个带有"JAVA_HOME"描述的JDK,这很奇怪,因为正如您所看到的,我的JAVA_HOME变量指向另一个JDK。我不确定这个列表问题是否与我看到的警告有关。

这就是我在~/.AndroidStudio3.6/config/options/jdk.table.xml文件中看到的:

cat ~/.AndroidStudio3.6/config/options/jdk.table.xml
<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="1.8" />
<type value="JavaSDK" />
<version value="java version &quot;1.8.0_252&quot;" />
<homePath value="$USER_HOME$/java/jdk8u252-b09" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/java/lib/jdkAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/charsets.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/cldrdata.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/dnsns.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/jaccess.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/localedata.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/nashorn.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/sunec.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/ext/zipfs.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/jce.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/jsse.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/management-agent.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/resources.jar!/" type="simple" />
<root url="jar://$USER_HOME$/java/jdk8u252-b09/jre/lib/rt.jar!/" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root url="jar://$USER_HOME$/java/jdk8u252-b09/src.zip!/" type="simple" />
</root>
</sourcePath>
</roots>
<additional />
</jdk>
<jdk version="2">
<name value="Android API 29 Platform" />
<type value="Android SDK" />
<version value="java version &quot;1.8.0_252&quot;" />
<homePath value="$USER_HOME$/bin/android-sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/bin/android-sdk/platforms/android-29/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/bin/android-sdk/platforms/android-29/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root url="file://$USER_HOME$/bin/android-sdk/sources/android-29" type="simple" />
</root>
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-29" />
</jdk>
<jdk version="2">
<name value="Kotlin SDK" />
<type value="KotlinSDK" />
<homePath value="$KOTLIN_BUNDLED$" />
<roots>
<annotationsPath>
<root type="composite" />
</annotationsPath>
<classPath>
<root type="composite" />
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional />
</jdk>
<jdk version="2">
<name value="1.8 (2)" />
<type value="JavaSDK" />
<version value="java version &quot;1.8.0_212&quot;" />
<homePath value="$APPLICATION_HOME_DIR$/jre" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/java/lib/jdkAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/charsets.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/cldrdata.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/dnsns.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/jaccess.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/localedata.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/nashorn.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/sunec.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/ext/zipfs.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/jce.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/jsse.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/management-agent.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/resources.jar!/" type="simple" />
<root url="jar://$APPLICATION_HOME_DIR$/jre/jre/lib/rt.jar!/" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="https://docs.oracle.com/javase/8/docs/api/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional />
</jdk>
<jdk version="2">
<name value="Android API 28 Platform" />
<type value="Android SDK" />
<version value="java version &quot;1.8.0_212&quot;" />
<homePath value="$USER_HOME$/bin/android-sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$USER_HOME$/bin/android-sdk/platforms/android-28/data/annotations.zip!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/bin/android-sdk/platforms/android-28/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/bin/android-sdk/platforms/android-28/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root url="file://$USER_HOME$/bin/android-sdk/sources/android-28" type="simple" />
</root>
</sourcePath>
</roots>
<additional jdk="1.8 (2)" sdk="android-28" />
</jdk>
</component>
</application>% 

并根据ps -x安卓工作室推出的嵌入式JDK:

ps -x | grep studio
28805 ?        S      0:00 /bin/sh /home/azabost/bin/android-studio-3.6/bin/studio.sh
28908 ?        Sl     5:06 /home/azabost/bin/android-studio-3.6/jre/bin/java -classpath /home/azabost/bin/android-studio-3.6/lib/bootstrap.jar:/home/azabost/bin/android-studio-3.6/lib/extensions.jar:/home/azabost/bin/android-studio-3.6/lib/util.jar:/home/azabost/bin/android-studio-3.6/lib/jdom.jar:/home/azabost/bin/android-studio-3.6/lib/log4j.jar:/home/azabost/bin/android-studio-3.6/lib/trove4j.jar:/home/azabost/bin/android-studio-3.6/lib/jna.jar:/home/azabost/bin/android-studio-3.6/jre/lib/tools.jar -Xms256m -Xmx1280m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -Dsun.io.useCanonPrefixCache=false -Djava.net.preferIPv4Stack=true -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf -Dkotlinx.coroutines.debug=off -Djdk.module.illegalAccess.silent=true -Djna.nosys=true -Djna.boot.library.path= -da -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine -Dsun.tools.attach.tmp.only=true -Xmx3072m -XX:ErrorFile=/home/azabost/java_error_in_STUDIO_%p.log -XX:HeapDumpPath=/home/azabost/java_error_in_STUDIO.hprof -Didea.paths.selector=AndroidStudio3.6 -Djb.vmOptionsFile=/home/azabost/bin/android-studio-3.6/bin/studio64.vmoptions,/home/azabost/.AndroidStudio3.6/config/studio64.vmoptions -Didea.platform.prefix=AndroidStudio -Didea.jre.check=true com.intellij.idea.Main

错误清楚地表明您已经在java目录中安装了android studio。据说要换个地方。U可以提供其他驱动器路径来安装工作室。从1.8下载java的升级版本https://www.oracle.com/in/java/technologies/javase-downloads.html同时更改现有目录中的路径。

相关内容

  • 没有找到相关文章

最新更新