gpt4 book ai didi

cordova - 运行cordova android build时Gradle使用错误的JAVA_HOME

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

更新:
我尝试删除 java openjdk 的所有痕迹,安装 Oracle Java 8,并再次设置我的环境变量,但仍然没有 bueno。所以在我做了source ~/.bashrc之后我关闭了所有终端,注销和中提琴,一切都已修复。不过真是麻烦。

操作:
我遇到了这个SO question这似乎解决了我遇到的同样问题。不幸的是,我没有这行 export JAVA_HOME=/usr/lib/jvm/default-java在我的usr/bin/gradle文件。

我的错误是 JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
但是echo $JAVA_HOME返回 /usr/lib/jvm/java-8-openjdk-amd64/jre
我尝试在真正的 JAVA_HOME 和一个 gradle 之间创建一个符号链接(symbolic link)一直尝试使用,但一个 gradle 尝试使用的不是真实的,所以我收到错误 ln: failed to create symbolic link '/usr/lib/jvm/java-7-openjdk-amd64/jre': No such file or directory

我尝试挖掘 gradlew 文件,发现我认为可能是有问题的代码,但我不能 100% 确定它是如何工作的,并且任何时候我编辑文件然后执行 cordova run android我所有的改变都被抹去了。

这是我在 gradlew 中找到的一段代码:

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

我的完整错误报告:
Running command: /home/grant/Development/Projects/ACA/hooks/after_prepare/icons_and_splashscreens.js /home/grant/Development/Projects/ACA
Running command: /home/grant/Development/Projects/ACA/hooks/after_prepare/update_platform_config.js /home/grant/Development/Projects/ACA
ANDROID_HOME=/home/grant/Development/Android
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
No target specified, deploying to device '05157df5a3d39408'.

ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-7-openjdk-amd64/jre

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

ERROR running one or more of the platforms: Error code 1 for command: /home/grant/Development/Projects/ACA/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/grant/Development/Projects/ACA/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to run this project

最佳答案

首先,Java home 应该看起来像 /usr/lib/jvm/java-8-oracle ,没有'jre'部分。
其次,它应该放在/etc/profile 文件中:
export JAVA_HOME="/usr/lib/jvm/java-8-oracle"export PATH=$JAVA_HOME/bin:$PATH

关于cordova - 运行cordova android build时Gradle使用错误的JAVA_HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39689963/

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