Reputation: 6131
After upgrading to flutter 3.19.0 i am getting the following error while running my application on android it is working fine on ios and when i open only android directory in android studio and run the project in that case also it is working fine.
ERROR:D8: com.android.tools.r8.kotlin.H
ERROR:D8: com.android.tools.r8.kotlin.H
ERROR:D8: com.android.tools.r8.kotlin.H
ERROR:D8: com.android.tools.r8.kotlin.H
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform firebase-auth-22.3.1.aar (com.google.firebase:firebase-auth:22.3.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/munsif/.gradle/caches/transforms-3/ba579288272952d282e3eb784bb3facc/transformed/jetified-firebase-auth-22.3.1-runtime.jar.
> Error while dexing.
> Failed to transform play-services-location-21.1.0.aar (com.google.android.gms:play-services-location:21.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/munsif/.gradle/caches/transforms-3/c40ae925c2dff28a07b701244ea18adb/transformed/jetified-play-services-location-21.1.0-runtime.jar.
> Error while dexing.
> Failed to transform recaptcha-18.4.0.aar (com.google.android.recaptcha:recaptcha:18.4.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/munsif/.gradle/caches/transforms-3/6a9b2598905fd8f95f3e5a4db9115179/transformed/jetified-recaptcha-18.4.0-runtime.jar.
> Error while dexing.
> Failed to transform kotlin-stdlib-1.9.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.9.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/munsif/.gradle/caches/transforms-3/ae0183353754275aa55a66ddf2de48d6/transformed/jetified-kotlin-stdlib-1.9.0.jar.
> Error while dexing.
I tried adding these to gradle.properties
android.useAndroidX=true
android.enableJetifier=true
enabling multiDex like this in build.gradle:
android {
defaultConfig {
...
multiDexEnabled true
}
}
add this line to build.gradle
implementation 'com.android.support:multidex:1.0.3'
all these methods didn't solved my problem: any solution for this problem?
Upvotes: 11
Views: 14295
Reputation: 1
I have tried changing the SDK version but nothing works. So, I updated the android gradle plugin and wrapper to 8.0+ and it works. Here is the detailed reason from this answer migrate your build gradle
Here is my updated AGP in my android/settings.gradle
id "com.android.application" version "8.1.1" apply false
That update made my flutter 3.19 running smoothly again
Upvotes: 0
Reputation: 1
this work for me. Write in app/android/build.gradle
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.appcompat') {
details.useVersion "1.6.1"
}
}
}
Upvotes: 0
Reputation: 61
Just change minSdk to 24
defaultConfig {
applicationId "com.example.app"
minSdk = 24
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
}
Upvotes: 4
Reputation: 5023
This error only happens when running the app locally (debugging). It should builds fine for release & debug with minSdkVersion 21.
Add the following to the /app/src/build.gradle file:
buildTypes {
debug {
minSdkVersion 21
signingConfig signingConfigs.debug
}
}
Upvotes: 0
Reputation: 11
In order to keep using minSdk=21, and still compile your project to sdk=34, use older gradle version.
Use classpath 'com.android.tools.build:gradle:7.3.0'
Upvotes: 1
Reputation: 241
Changing minSdkVersion
solved it for me. When having minSdkVersion
21 i had the exact same issue, increasing it to 24 solved the issue for me.
minSdkVersion 24
Upvotes: 24
Reputation: 10840
Munsif's answer works, but Flutter supports minSdk 21. Additionally, firebase also supports sdk 21. as well. There is no reason to remove support for older SDKs.
So each persons specific build issue might be slightly different. But you need to migrate your build.gradle files to use the new declarative plugins block. This is very important as you may need to update your android gradle plugin and wrapper to 8.0+. This requirement depends on your libraries. But if you can get it working, it's best to do so.
To quote the most important part of that link above:
To build a Flutter app for Android, Flutter's Gradle plugins must be applied. Historically, this was done imperatively with Gradle's legacy, imperative apply script method.
In Flutter 3.16, support was added for applying these plugins with Gradle's declarative plugins {} block (also called the Plugin DSL) and it is now the recommended approach. Since Flutter 3.16, projects generated with flutter create use the Plugin DSL to apply Gradle plugins. Projects created with versions of Flutter prior to 3.16 need to be migrated manually.
The key part here is, manually. After you do that, update your AGP to something 8.0+. In my case I did:
id "com.android.application" version "8.1.1" apply false
Fix any build issues that arise from that based on your specific needs. I had the exact same build issue, but got flutter on Android running again on 3.19 without needing to bump the minSdk
version to 24.
Upvotes: 2
Reputation: 6131
Changing the compileSdkVersion solved my problem.
I changed compileSdkVersion
in android/app/build.gradle
From
compileSdkVersion flutter.compileSdkVersion
TO
compileSdkVersion 33
and the error gone.
EDIT:
I got the same issue when i change the compile sdk to 34 which flutter recommended me because i was using url_launcher and video_player which use compileSdk 34. and as i changed the compileSdkVersion to 34 i got the same issue again and that i solved by changing the minSdkVersion
to 24 from 21
Change From
minSdkVersion 21
To
minSdkVersion 24
Thanks to Johnyp
Upvotes: 12