Closed mehrdad1990 closed 1 month ago
same issue
same issue @AmrTawfek try this version in settings.gradle. Seems to sort out the issue for now:
id "com.android.application" version "8.3.2" apply false
same issue @AmrTawfek try this version in settings.gradle. Seems to sort out the issue for now:
id "com.android.application" version "8.3.2" apply false
thanks @mehrdad1990 , I will try it because when I countered this issue I downgraded my IDE version to latest working one
what is the Gradle version you use please in distributionUrl? @mehrdad1990
Getting same issue on MacOS.
Downgrading the AndroidStudio did not fix the issue
* What went wrong:
Execution failed for task ':device_info_plus:compileReleaseJavaWithJavac'.
> Could not resolve all files for configuration ':device_info_plus:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /Users/daksh-gargas/dev/Android/sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path /Users/daksh-gargas/.gradle/caches/transforms-3/e8dfe22a750ee0e24ac6b098f580808c/transformed/output/temp/jmod --add-modules java.base --output /Users/daksh-gargas/.gradle/caches/transforms-3/e8dfe22a750ee0e24ac6b098f580808c/transformed/output/jdkImage --disable-plugin system-modules}
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* What went wrong:
Execution failed for task ':connectivity_plus:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'.
Same problem, but I resolved it with updating AGP version (from 7.3.0):
id "com.android.application" version "8.3.0" apply false
Unfortunately updating to a newer AGP requires some additional tweaks.
what is the Gradle version you use please in distributionUrl? @mehrdad1990
@adham-ashraf77 this is the version : gradle-8.6-all
same for me. I am unable to use workaround with updating AGP version because it affects other packages :(
same for me. I am unable to use workaround with updating AGP version because it affects other packages :(
We have a huge app that use a lot of dependencies, I migrated AGP and all affected packages, I had to fork some myself unfortunately. But know it works.
same for me. I am unable to use workaround with updating AGP version because it affects other packages :(
We have a huge app that use a lot of dependencies, I migrated AGP and all affected packages, I had to fork some myself unfortunately. But know it works.
Yep, that's the way, but I don't want to fork other packages if there's a chance of a possible fix
seems working with latest
id "com.android.application" version "8.7.0" apply false
the same issue, all tricks failed
This worked for me:
id "com.android.application" version "8.7.0" apply false
same issue
Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'.
Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for JdkImageTransform: /Users/algooceansmacbook/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar. Error while executing process /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path /Users/algooceansmacbook/.gradle/caches/transforms-3/b7ad379871a160c29269eed9ca2ef736/transformed/output/temp/jmod --add-modules java.base --output /Users/algooceansmacbook/.gradle/caches/transforms-3/b7ad379871a160c29269eed9ca2ef736/transformed/output/jdkImage --disable-plugin system-modules}
same issue
Fixed issue by using:
id "com.android.application" version "8.7.0" apply false
in plugins block In android/settings.gradle
Also set in gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
Currently using Java version:
java version "1.8.0_301"
Fixed issue by using:
id "com.android.application" version "8.7.0" apply false
in plugins block In android/settings.gradle
yes this work for me additionally need to set distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
Which Java/JDK-Version are you using in your projects for those solutions?
Thanks to everyone for helping each other fix the compilation issue. I am marking this issue as completed, but I pinned it so it is easier to find.
Please do as said by malwinder-s:
Fixed issue by using:
id "com.android.application" version "8.7.0" apply false
in plugins block In android/settings.gradleAlso set in gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
Please do as said by malwinder-s:
Fixed issue by using:
id "com.android.application" version "8.7.0" apply false
in plugins block In android/settings.gradle Also set in gradle-wrapper.properties:distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
When doing so, I get the error:
Your project is configured with Android NDK 23.1.7779620, but the following plugin(s) depend on a different Android NDK version:
- connectivity_plus requires Android NDK 27.0.12077973
- ....
My android parameters inside my build.gradle
look like this:
android {
namespace "my_app"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "my_app"
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
I use Android Studio Ladybug 2024.2.1. Before, with Koala and lower Gradle-version, everything worked fine.
Do you need to specify the ndkVersion
? We don't set that in any plugin project or any example project
I had the same issue, in "gradle-wrapper.properties" raised the version to:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
and in the "app/build.gradle" put:
plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.3.2" apply false id "org.jetbrains.kotlin.android" version "1.8.22" apply false }
But now i have another problem, my Release APK doenst have icon anymore and crash on installing... anyone know what is it? This is my "flutter doctor --verbose": ` [√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [versÆo 10.0.22631.4169], locale pt-BR) • Flutter version 3.24.3 on channel stable at c:\src\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (3 weeks ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at C:\Users\Takeo\AppData\Local\Android\sdk • Platform android-35, build-tools 35.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.7.34031.279 • Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2024.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
[√] VS Code (version 1.94.0) • VS Code at C:\Users\Takeo\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.98.0
[√] Connected device (4 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.22631.4169] • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.122 • Edge (web) • edge • web-javascript • Microsoft Edge 129.0.2792.65
[√] Network resources • All expected network resources are available.
• No issues found!`
Dont have errors on building apk.
Do you need to specify the
ndkVersion
? We don't set that in any plugin project or any example project
flutter create -a
creates this specification automatically, but I deleted the line now.
By doing so I got a step further, but my build stills fails:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kiosk_mode:compileDebugKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (21).
But this problem seems to be related to pub.dev package "kiosk_mode" not being compatible with newer JDK/Gradle-versions, if I understand the error correctly.
Created a pinned issue with some more details on how to fix the recent Android compilation issues https://github.com/fluttercommunity/plus_plugins/issues/3303
Same issue how to fix
What went wrong: Execution failed for task ':connectivity_plus:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for JdkImageTransform: /Users/khanarif/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar. Error while executing process /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path /Users/khanarif/.gradle/caches/8.10.2/transforms/032038f8b1fb7c8315d3916879a27cfe-f7a9d0f7-cfbc-4af5-bdad-53af67d8e3fe/transformed/output/temp/jmod --add-modules java.base --output /Users/khanarif/.gradle/caches/8.10.2/transforms/032038f8b1fb7c8315d3916879a27cfe-f7a9d0f7-cfbc-4af5-bdad-53af67d8e3fe/transformed/output/jdkImage --disable-plugin system-modules}
pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath } settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
plugins { id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false } }
include ":app"
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
If you've encountered issues after upgrading to Android Studio LadyBug, here's how you can resolve them:
Modify settings.gradle
File:
settings.gradle
file, add the following line:
id "com.android.application" version "8.3.2" apply false
Gradle Plugin Error:
gradle-wrapper.properties
file with the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
After making these changes, clean and rebuild your project to ensure everything compiles correctly.
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction An issue was found when checking AAR metadata:
Dependency ':flutter_local_notifications' requires core library desugaring to be enabled for :app.
See https://developer.android.com/studio/write/java8-support.html for more details.
Try:
Run with --stacktrace option to get the stack trace. 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.
BUILD FAILED in 8s Error: Gradle task assembleDebug failed with exit code 1
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:checkDebugAarMetadata'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction An issue was found when checking AAR metadata:
1. Dependency ':flutter_local_notifications' requires core library desugaring to be enabled for :app. See https://developer.android.com/studio/write/java8-support.html for more details.
- Try:
Run with --stacktrace option to get the stack trace. 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.
BUILD FAILED in 8s Error: Gradle task assembleDebug failed with exit code 1
add this found in docs
If you dont want to go for this solution what I have applied is added specific JDK version using gradle.properties
.
org.gradle.java.home=<Your java version path>
.
I have set JDK 11 for my project which was running good on Android Studio Koala.
It doesn't work for me for this workaround:
id "com.android.application" version "8.3.2" apply false
but finally I figured it out by this command:
flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/home
change the argument to your own JDK path.
What should I do if the java version is 21. Should I update it to 17 and complete the other steps.
What should I do if the java version is 21. Should I update it to 17 and complete the other steps.
Had the same issue and this worked -> link
I have to downgrade Android Studio version to Koala 2024.1.2 Patch 1 and it works.
Any news, fail in ios
It doesn't work for me for this workaround:
id "com.android.application" version "8.3.2" apply false
but finally I figured it out by this command:
flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/home
change the argument to your own JDK path.
This works for me
It doesn't work for me for this workaround:
id "com.android.application" version "8.3.2" apply false
but finally I figured it out by this command:
flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/home
change the argument to your own JDK path.
Dos not work for me in case I want to code native kotlin/java
I had to downgrade Java to version 17 and change the version in settings.gradle from
id "com.android.application" version "7.3.0" apply false
to
id "com.android.application" version "8.7.0" apply false
Now it works without any issues. Important: Don’t forget to adjust the environment variable accordingly.
Below is the complete steps for updating a Flutter Android app to support the latest Android Gradle Plugin (AGP) with all necessary changes.
android/app/build.gradle
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
android {
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
defaultConfig {
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
}
android/gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
android/build.gradle
subprojects {
afterEvaluate {
if (it.hasProperty('android')) {
it.android.compileSdkVersion = 35
it.android.defaultConfig.targetSdkVersion = 35
it.android.compileOptions.sourceCompatibility = JavaVersion.VERSION_21
it.android.compileOptions.targetCompatibility = JavaVersion.VERSION_21
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = JavaVersion.VERSION_21
}
if (it.android.namespace == null) {
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
def packageName = manifest.@package.text()
android.namespace = packageName
println("Updating namespace ${packageName}")
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
android/settings.gradle
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.1" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
}
These changes update your Flutter Android project to be compatible with the latest AGP version, by specifying new plugin versions, aligning SDK levels, managing Java compatibility, and correctly configuring the build logic to align with the updates. Make sure to test your app thoroughly after making these changes to ensure stability and compatibility.
after changing these - ndkVersion = "27.0.12077973" in app/build.gradle, id "com.android.application" version "8.7.0" apply false this in settings.gradle
plugins { ------- this shows - Gradle execution is not trusted on this project. id "com.android.application" id "kotlin-android" // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" }
android { namespace = "com.example.internet_checker_app" compileSdk = flutter.compileSdkVersion ndkVersion = "27.0.12077973"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.internet_checker_app"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.debug
}
}
}
flutter { source = "../.." }
app/build.gradle file
allprojects { this line also shows --- Gradle execution is not trusted on this project. repositories { google() mavenCentral() } }
rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(":app") }
tasks.register("clean", Delete) { delete rootProject.buildDir } android/build.gradle file
how can i slove this after upgrading all
My changes helps me to resolve this problem to use java 21 in my Flutter project:
android\settings.gradle
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.1" apply false
id "org.jetbrains.kotlin.android" version "1.9.24" apply false
}
android/app/build.gradle
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
android\gradle\wrapper\gradle-wrapper.jar
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
is all changes after upgrade from koala to ladybug. if needed , do not forgot update flutter plugins to last version i.e. device_info_plus: ^11.1.0
if u get warnings about NDK ...
Your project is configured with Android NDK 23.1.7779620, but the following plugin(s) depend on a different Android NDK version:
- connectivity_plus requires Android NDK 27.0.12077973
Fix this issue by using the highest Android NDK version (they are backward compatible).
Add the following to ......android\app\build.gradle:
android {
ndkVersion = "27.0.12077973"
...
}
u can add this line or u comment this line like me
// ndkVersion = flutter.ndkVersion
then i use current NDK :-)
It doesn't work for me for this workaround:
id "com.android.application" version "8.3.2" apply false
but finally I figured it out by this command:
flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/home
change the argument to your own JDK path.
this works for me. thanks!
Run the following command to clean up old build files: flutter clean
Open the project in Android Studio. Launch the AGP Upgrade Assistant:
- Run the following command to clean up old build files: flutter clean
This helped me run my project. I will note that I do have warnings when I run my project but it works. I want to add a few more details to help with this.
Open the project in Android Studio. Launch the AGP Upgrade Assistant:
- Go to the top menu, and select Tools. -Then, click on AGP Upgrade Assistant. Once complete, the issue will be resolved.
In your finder/file explorer, go to your flutter project and navigate to your android folder. Open this in Android Studio, otherwise you will not be able to use the AGP Upgrade Assistant. Once you have opened your android folder in AS then you should be able to launch this AGP Upgrade Assistant.
Operating System
Windows 11
Plugin
connectivity_plus
Version
6.0.5
Flutter SDK
Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 2663184aa7 (3 weeks ago) • 2024-09-11 16:27:48 -0500 Engine • revision 36335019a8 Tools • Dart 3.5.3 • DevTools 2.37.3
Compilation command
running the project normally in Android Studio: flutter run flutter debug
Dart Dependencies
No response
Native dependencies
No response
Compilation Error
Flutter Doctor
Checklist before submitting a bug
flutter pub upgrade
flutter clean