gpt4 book ai didi

macos - Gradle在Mac中为JAVA_HOME获取错误的值

转载 作者:行者123 更新时间:2023-12-03 03:42:36 26 4
gpt4 key购买 nike

当尝试使用gradle从Jenkins构建android应用程序时,我
得到以下错误:

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-oracle
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

但是,当我检查JAVA_HOME变量时,我得到:
Macs-Mac-mini:~ mac$ echo $JAVA_HOME 
/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home

运行 java -version
Macs-Mac-mini:~ mac$ java -version 
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

为什么Gradle找到 /usr/lib/jvm/java-8-oracle
尝试过 Gradle finds wrong JAVA_HOMEGradle does not recognize the JAVA_HOME

最佳答案

经过大量调试后,我发现Gradle是从Jenkins主JDK配置中获取$ JAVA_HOME变量值,而不是从节点的$ JAVA_HOME变量中获取。

我从Jenkins主服务器上删除了默认的JDK配置路径,Gradle从节点上获取了$ JAVA_HOME变量值。

关于macos - Gradle在Mac中为JAVA_HOME获取错误的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40862755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com