Closed FranGhe closed 2 days ago
The error is occurring on the gradle wrapper install which uses the system gradle.
General error during semantic analysis: Unsupported class file major version 61
Means that it doesn't support the JDK environment, major version 61 is the internal java code for JDK 17. So this leads me to believe you're running a rather old version of gradle at the system level.
What version is your system gradle? e.g. what does gradle -v
print?
Most of the time system gradle doesn't matter as long as it can install the wrapper, but if it's dated enough to fail on the wrapper install, it will be time to upgrade. I recommend using the latest gradle 8.x release available, which at the time of writing, is version 8.9. Alternatively you can install 8.7 which I know is compatible with cordova-android@13. I think the absolute minimum is 8.5, due to AGP requirements.
Let me know if this helps.
You are (as always) very very helpful... thank you!
Yes, I needed to update my system Gradle.
I mistakenly thought that it was enough to update the Android Studio Gradle... but Cordova prepares the project for Android Studio, so it must have the necessary tools first...
So... this should be the correct planning, right?
1) Update Java to JDK17 and set Enviroment Variables (JAVA_HOME)
2) Update Gradle to 8.7 and set Enviroment Variables (PATH)
3) Update config.xml (
... than "cordova build"
By Android Studio AGP Upgrade assistant - update Android Gradle Plugin 8.3.0 to Gradle 8.7
The AGP and Gradle are two different things.
Gradle is the build system. AGP (Android Gradle Plugin) is a plugin for that build system to build android applications and kibraries. I would avoid updating the AGP, they tend to introduce breaking changes. Android Studio will prompt you to update it, but avoid doing so.
Everything else looks right, going by memory... I'm mobile atm.
I am using gradle 8.7 and java 17 in my docker image. I am getting following error while executing cordova build android
in docker container which is using beevelop/android image.
220.8 Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
Could anyone help me. Thanks in advance
I would like to add to the Google Search results that upgrading Gradle, as pointed by Norman, did solve the completely different error message I got, which I must say is the same marked as off-topic from @Krantikc (so I guess it's not _that_off-topic and, I guess, what helped Google bring me here):
FAILURE: Build failed with an exception.
* What went wrong: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory(). > Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
I was running Gradle 4.4.1, which worked fine with SDK 33 and cordova-android 13. When I moved to SDK 34, it complained about JDK 11:
FAILURE: Build failed with an exception.
* Where: Build file '/home/[...]/my-project-folder/platforms/android/app/build.gradle' line: 20
* What went wrong: A problem occurred evaluating project ':app'. > Failed to apply plugin 'com.android.internal.application'. > Android Gradle plugin requires Java 17 to run. You are currently using Java 11. Your current JDK is located in /usr/lib/jvm/java-11-openjdk-amd64 You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing
org.gradle.java.home
ingradle.properties
.
Then I upgraded to 17 and that new error started popping up, and it went away with Gradle 8.7, which I downloaded as instructed from that releases' page, and properly placed it above the system one on my $PATH
.
Also, I had to, as usual, remove and re-add the android platform, as mentioned by the OP; otherwise, I would be getting the following complaint:
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34
This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33
Thanks, Norman! (not tagging you, since you definitely are busier enough without having to read messages where you don't need to act upon)
Closing because I don't believe there is a bug here or anything actionable by Cordova.
I'm workig to update my app to Android14 (API-Level34) and as always when I have to update... it's a headache. This is my timing actions: 1) I updated my "android-targetSdkVersion" a 34 in config.xml
Than I build the project by "cordova build" and:
What's wrong?