简体   繁体   中英

Cordova build error "Requirements check failed for JDK 8 ('1.8.*')! Detected version: 11.0.2"

when I try to compile with ionic my application tells me the following error:

Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=/home/jmarroni/Android/Sdk (DEPRECATED) Requirements check failed for JDK 8 ('1.8.*')! Detected version: 11.0.2 Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables. [ERROR] An error occurred while running subprocess cordova.

Try installing the previous version of java 1.8 but do not recognize the change.

I've faced the same problem. In my case, two different JDK are installed

/usr/lib/jvm$ default-java java-1.11.0-openjdk-amd64 java-11-openjdk-amd64 java-1.8.0-openjdk-amd64 java-8-openjdk-amd64 openjdk-11

  1. sudo update-alternatives --config java
  2. sudo update-alternatives --config javac

I will put in one place all the information:

  • Version 8 of Java JDK. I was unable to find quickly the openjdk-8 version, so I decided to install Oracle version
  • Setting JAVA_HOME is not needed
  1. Proceed to

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

  1. Download:
jdk-8u251-linux-x64.tar.gz or newest 
  1. Login with oracle account

  2. Uncompress it in /opt

sudo cp ~/Desktop/jdk-8u251-linux-x64.tar.gz /opt
cd /opt
sudo tar xfz jdk-8u251-linux-x64.tar.gz
sudo ln -s jdk1.8.0_251 java
  1. Make java binary point to desired SDK

5.1. Install alternative

sudo update-alternatives --install /usr/bin/java java /opt/java/bin/java 2

5.2. Activate it

sudo update-alternatives --config java

5.3. Select the entry added in step 4.1.

There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-14-openjdk-amd64/bin/java   1411      auto mode
  1            /opt/java/bin/java                            2         manual mode
  2            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
  3            /usr/lib/jvm/java-14-openjdk-amd64/bin/java   1411      manual mode

In this case type 1 and press Enter

5.4. Test

Type:

java -version

Expected output similar to:

java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
  1. Make javac binary point to desired SDK

6.1. Install alternative

sudo update-alternatives --install /usr/bin/javac javac /opt/java/bin/javac 2

6.2. Activate it

sudo update-alternatives --config javac

6.3. Select the entry added in step 6.1.

There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-14-openjdk-amd64/bin/javac   1411      auto mode
* 1            /opt/java/bin/javac                            2         manual mode
  2            /usr/lib/jvm/java-14-openjdk-amd64/bin/javac   1411      manual mode

In this case type 1 and press Enter

6.4. Test

Type:

javac -version

Expected output similar to:

javac 1.8.0_251

if the output is similar to the output of "java -version", make sure you've written the correct command in section 6.1 with the missing "c" of the original post.

Worked for me. PAY ATTENTION! 6.1 : the original post had a typo (a missing "c"). the command should be: "sudo update-alternatives --install /usr/bin/javac javac /opt/java/bin/javac 2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM