Closed GitFr33 closed 9 months ago
There are 2 things that I see...
Cordova uses AGP 7.x (7.4.2) which is only compatible Gradle 7 and there are known issues when trying to initialize the wrapper on gradle 8 (at least in 8.0, maybe that's fixed now). So try having a system gradle 7 instead of 8.
Second, which it seems that you're running Java 8. Java 11 is required. Make sure your JAVA_HOME or CORDOVA_JAVA_HOME is set to a JDK 11 environment .
Thanks for your help @breautek. You were correct, although I had Java 11 selected with update-alternatives my JAVA_HOME was pointing to java 8. Fixing that helped — but now I'm getting the following error:
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
root project 'Project Name' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
I'm not sure if this is due to an out of date plugin or due to using gradle 8 instead of 7 but I'm confused about the relation or difference between Gradle version and Android Gradle plugin versions.
My projects gradle-wrapper.properties file defines: distributionUrl=https://services.gradle.org/distributions/gradle-7.6-all.zip
likewise cdv-gradle-config.json "GRADLE_VERSION":"7.6"
and "AGP_VERSION":"7.4.2"
but running gradle -v
returns Gradle 8.1.1
and I'm not sure what's the correct way to downgrade it.
Everything I've found about downgrading to a previous version of gradle has to do with project level gradle version such as defined in gradle-wrapper.properties
I'm not sure if this is due to an out of date plugin or due to using gradle 8 instead of 7 but I'm confused about the relation or difference between Gradle version and Android Gradle plugin versions.
To put it simply, Gradle is a build system. It's mainly used for Java/Kotlin projects. The Android Gradle Plugin is Android's Gradle extension to support building Android libraries and applications.
As of 7.x, Android's Gradle Plugin version scheme is their major version dictates the supported version of Gradle itself. So AGP 7.x will run on Gradle 7.
Gradle has a concept of "wrappers" which is a project-level install of Gradle, at the version that the project needs. Gradle 8.0 would not properly initialize a gradle 7 wrapper, but it appears that has been fixed in some patch, at least in 8.1. So downgrading your system gradle is probably not necessary.
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher. The following dependencies do not satisfy the required version: root project 'Project Name' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20
As for this, it's kinda interesting. Do you have GradlePluginKotlinVersion
defined? The defualt version on cordova-android@12 should be 1.7.21
. You can try setting the preference in your config.xml
:
<preference name="GradlePluginKotlinVersion" value="1.7.21" />
I'd also try doing a search in folder of the plugins/
directory and see if any plugins is either defining GradlePluginKotlinVersion
in their plugin.xml
files, or if they are declaring any dependencies on org.jetbrains.kotlin:kotlin-gradle-plugin
themselves.
I super appreciate your help @breautek! I did indeed find a plugin specifying a GradlePluginKotlinVersion and building succeeded after specifying GradlePluginKotlinVersion in config.xml
Failed to apply plugin 'com.android.internal.application'. Could not create an instance of type com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated. Could not create an instance of type com.android.build.gradle.internal.dsl.LintImpl$AgpDecorated. Could not generate a decorated class for type LintImpl$AgpDecorated. com/android/tools/lint/model/LintModelSeverity has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
Bug Report
Problem
Build fails with
Could not resolve com.android.tools.build:gradle:7.4.2
after updating android platform to version 12.0.0What is expected to happen?
Build succeeded
What does actually happen?
Build failed
Information
Command or Code
cordova build android --debug
Environment, Platform, Device
Environment: Ubuntu 22.04 Platform: cordova-android Device: none
Version information
Cordova CLI 11.1.0 Cordova platform android 12.0.0 Operating System: Ubuntu 22.04 Android sdk build tools: 33.0.2 openjdk version: 11.0.19 Gradle: 8.1.1 (though the
Deprecated Gradle features...
output makes me wonder about what version of gradle is actually being used...)Checklist