Skip to content
Advertisement

Java 11 requirements check failed for JDK 1.8 or greater with Cordova

When I run ““cordova run android“` in the path of my project I get

Android Studio project detected
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/cordova-android-support-gradle-release/norsan-cordova-android-support-gradle-release.gradle
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Requirements check failed for JDK 1.8 or greater

My version of Java

$ java --version
openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.119.04)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.119.04, mixed mode, sharing)

My version of javac

$ javac --version
javac 11.0.5

My version of Cordova

$ cordova --version
9.0.0 (cordova-lib@9.0.1)

My version of Node

$ node --version
v10.15.2

My version of Nodejs

$ nodejs --version
v10.15.2

My version of NPM

$ npm --version
5.8.0

My version of Gradle

$ gradle -version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/java/groovy-all.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------

Build time:   2012-12-21 00:00:00 UTC
Revision:     none

Groovy:       2.4.16
Ant:          Apache Ant(TM) version 1.10.5 compiled on March 28 2019
JVM:          11.0.5 (Private Build 11.0.5+10-post-Ubuntu-0ubuntu1.119.04)
OS:           Linux 5.0.0-38-generic amd64

I found that android-studio --version didn’t do anything but silently wait, but when I open the program through the graphical user interface I see that the version is 3.6.1.

My version of androidsdk is Unknown… Not sure why.

$ androidsdk --version
SDK_ROOT=/home/galen/snap/androidsdk/21/AndroidSDK
Picked up _JAVA_OPTIONS: -Duser.home=/home/galen/snap/androidsdk/21
Unknown version

My version of Ubuntu

$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.04
DISTRIB_CODENAME=disco
DISTRIB_DESCRIPTION="Ubuntu 19.04"
NAME="Ubuntu"
VERSION="19.04 (Disco Dingo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.04"
VERSION_ID="19.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=disco
UBUNTU_CODENAME=disco

My understanding is that Java 11 comes later than JDK 1.8, so why does the requirements check fail? And, how do I fix this requirements check failure?

Advertisement

Answer

Update:

Java 11 is supported for cordova 10+ which allows for the same minimum Android versions as cordova 9. This should now be the preferred solution.


Original answer (for reference):

You are correct that Java 11 is more recent than JDK 1.8 and that it should work in theory.

However, cordova explicitly requires JDK 1.8 still:

Android doesn’t use oracles java but their own implementation, which at the moment is like java 8. So this is an android limitation, not something cordova can fix.

(cf. also issue 510)

Their development guide explicitly mentions JDK 1.8 as well:

Java Development Kit (JDK)

Install Java Development Kit (JDK) 8.

So the fix for now would be installing JDK 1.8 (if you go for Oracle note their recently changed license terms). You may watch PR 928 that attempts to ease that restriction, though.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement