I had to install a new plugin but in order to start fresh, I removed my platform/android folder and did run
cordova prepare android
. Without realising it, cordova-android when from version 10 to 8 causing the following side effects:
Incompatible JDK (11 installed) but 1.8 is expected
First thing that caught me was the following error:
cordova prepare android`
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 11.0.2
Everything was working fine. What’s going wrong?
I did downgrade to JDK 8 using sdkman.
sdk install java 8.0.302-zulu
It worked, but then the problem was something else. JDK version was incompatible with gradle 8.
JDK 8 is incompatible with gradle 8
Ok, this is too weird right? I must have done something wrong… That’s when I noticed the cordova-android@8 installed. I couldn’t believe -.-‘.
Fixing things up
$ sdk install java 11.0.19-zulu
$ sdk default java 11.0.19-zulu
# SDK 11 is the required version for platform android@10
# see more here:
# https://cordova.apache.org/announcements/2021/07/20/cordova-android-10.0.0.html
# Now remove the cordova platform
$ cordova platform rm android
# Now add the cordova platform with correct version
$ cordova platform add cordova-android@11
$ cordova run android --device
# And that it. Everything is now working.
Bonus tip:
In cordova-android@10 there’s a new variable allowing you to have a dedicated JAVA_HOME for cordova apps.
CORDOVA_JAVA_HOME