Ionic 2 构建 android 失败(JDK 1.8 或更高版本的需求检查失败)



我正在尝试在 Ubuntu 上运行ionic cordova build android并收到以下错误:

You have been opted out of telemetry. To change this, run: cordova telemetry on.
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Error: Requirements check failed for JDK 1.8 or greater

如您所见,JAVA_HOME指向JDK 8。

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

这是ionic info的输出

global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.5.0
local packages:
@ionic/app-scripts              : 2.0.2
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 3.5.3
System:
Node       : v8.2.1
OS         : Linux 4.4
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 5.3.0 

我错过了什么?

编辑

安装oracle jdk后,我仍然遇到相同的错误。

You have been opted out of telemetry. To change this, run: cordova telemetry on.
ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-1.8.0-oracle
Error: Requirements check failed for JDK 1.8 or greater
$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-oracle
$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

/usr/bin/javac 指向 JDK 7。使用命令将其更改为指向OpenJDK版本 8sudo update-alternatives --config javac一切都很好。我现在能够构建它 - 即使使用OpenJDK 8 java,所以不需要安装oracle jdk。

相关内容

  • 没有找到相关文章

最新更新