flutter build apk
works fine, but flutter run
fails:
> flutter run
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
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 play-services-location-21.2.0.aar (com.google.android.gms:play-services-location:21.2.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=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/simon/.gradle/caches/transforms-3/98c4a6e3b02ea90add92b8bb905a6138/transformed/jetified-play-services-location-21.2.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=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /home/simon/.gradle/caches/transforms-3/c844a9fd543cd48e051ebc5bfa89f9fa/transformed/jetified-kotlin-stdlib-1.9.0.jar.
> Error while dexing.
* 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 50s
Running Gradle task 'assembleDebug'... 50.8s
The following patch fixes it, I wonder why...
diff --git a/android/app/build.gradle b/android/app/build.gradle index 67e7646e215a..3e8b693bea0e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -79,6 +79,9 @@ android { signingConfig signingConfigs.debug } } + debug { + minifyEnabled true + } } }
Ah, actually, upgrading AGP to 8.0+ also fixes the issue (see the
agp-8.4
branch). Unfortunately two plugins need new releases to add compatibility with AGP 8.0+ (flutter_background
andwebcrypto
).(Ref https://stackoverflow.com/questions/78113826/failed-to-transform-firebase-auth-22-3-1-aar )
Simon Ser referenced this ticket in commit 7b40108.