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

偶尔善良 提交于 2020-06-16 07:43:13

问题


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.


回答1:


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-jdk8-downloads.html

  1. Download:
jdk-8u251-linux-x64.tar.gz
  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.




回答2:


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



回答3:


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"



来源:https://stackoverflow.com/questions/56634445/cordova-build-error-requirements-check-failed-for-jdk-8-1-8-detected-ver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!