0

$ cordova build android –release
When JAVA_HOME points to old C:\Program Files\Java\jdk1.8.0_261 - I get:
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
When JAVA_HOME points to new C:\Program Files\Java\jdk-17.0.2 - I get:
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 17.0.2
How do I solve this?

Free Bud
  • 746
  • 10
  • 30

2 Answers2

0

You should download the latest version

Narendra_Nath
  • 4,578
  • 3
  • 13
  • 31
Gilluisf
  • 41
  • 4
0

Older versions of cordova-android required Java 8, which was requirements from the parts & versions of Android SDK cordova used. There is a Android SDK / cordova-android version mismatch in your environment.

As of cordova-android@10 (current version at the time of writing), the Java 8 restriction was opened up to allow Java 11 as cordova-android was updated to use more modern versions of the Android SDK which consequentially requires Java 11.

Requirements check failed for JDK 8 ('1.8.*')

Not sure which cordova-android version you're running but this error definitely means you aren't running cordova-android@10, so I'd suggest to update the cordova-android platform.

cordova platform remove android
cordova platform add android@10

I'd also suggest ensuring you're running cordova cli verison 10 or later as well. (Checkable via cordova -v)

Norman Breau
  • 2,132
  • 16
  • 35
  • 1
    Thanks. I noticed cordova 11 released recently (https://cordova.apache.org/news/2021/12/21/cordova-cli-11.0.0-release.html) - Isn't it better to go directly for this? – Free Bud Feb 09 '22 at 11:00
  • Ideally yes. cordova cli 11 actually pins cordova-android 10 by default (that is if you don't specify the version it will install version 10 of cordova-android) – Norman Breau Feb 09 '22 at 15:37
  • Sorry for my ignorance: Is there a difference between npm uninstall/install and cordova platform remove/add? I did the former and still getting the "Requirements check failed for JDK 8"... – Free Bud Feb 09 '22 at 18:56
  • Yes. npm install/uninstall simply adds/removes the packages from your node_modules. the cordova command actually manages the cordova project. cordova uses NPM behind the scenes to add/remove packages. – Norman Breau Feb 09 '22 at 20:48
  • Well, after the cordova platform remove/add - the java error has gone. I have a different error now though, but that's for a different question. Thanks! – Free Bud Feb 10 '22 at 07:32
  • It appears that following the cordova platform remove/add - the platforms\android\gradle folder has gone. My new problem seems to be related to this: https://stackoverflow.com/questions/58293436/could-not-compile-settings-gradle-react-native – Free Bud Feb 10 '22 at 07:46