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

时间:2017-08-01 12:26:37

标签: java android ionic2

我正在尝试在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)

1 个答案:

答案 0 :(得分:1)

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