我在我的应用程序中使用cordova。
我跑了命令
сordova platform add android
Using cordova-fetch for cordova-android@^8.0.0
Platform android already added.
然后cordova构建并看到以下错误
hacking Java JDK and AndroidSDKversions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/usr/lib/android-sdk (DEPRECATED)
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java/bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
readlink-f $(java)命令显示
/usr/lib/jvm/java-8-oracle/jre/bin/java
我很困惑和不安,如何解决这个问题?
我改变了我的.bashrc并添加了字符串
setenv JAVA_HOME /usr/lib/jvm/java-8-oracle/jre/
setenv PATH $JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
如果我现在运行echo $ JAVA_HOME,我看到了
/usr/lib/jvm/java-8-oracle
我看到我运行了cordova构建
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/usr/lib/android-sdk (DEPRECATED)
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
Unable to start the daemon process.
怎么了?
这似乎没有为java_home设置环境变量,通过以管理员身份运行它从命令提示符shell中尝试此操作,虽然您可以根据需要重新启动计算机。
setenv JAVA_HOME /usr/lib/jvm/java-8-oracle/jre/
setenv PATH $JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH