问题
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- Proceed to
https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
- Download:
jdk-8u251-linux-x64.tar.gz
Login with oracle account
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
- 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)
- 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
- sudo update-alternatives --config java
- 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