Chloé
Chloé

Reputation: 1129

Failed to transform firebase-auth-22.2.0.aar

I am getting this error.

Failed to transform firebase-auth-22.2.0.aar (com.google.firebase:firebase-auth:22.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}.

I tried to update kotlin, build gradle, all libraries, flutter clean, invalidate cache... nothing work.

Here is my configuration

ext.kotlin_version = '1.8.22'
minSdkVersion 21
targetSdkVersion 34

classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.0'
    
implementation platform('com.google.firebase:firebase-bom:31.2.0')

What else I can do ?

Upvotes: 15

Views: 7047

Answers (3)

Andy
Andy

Reputation: 10840

Chloe'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 decleretive 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: 1

gblue1223
gblue1223

Reputation: 421

minSdkVersion 24 didn't work for me. I solved it with below, don't know why, through.

        debug {
            // fix Failed to transform firebase-auth-22.3.1.aar
            minifyEnabled true
            signingConfig signingConfigs.debug
        }

Upvotes: 19

Chloé
Chloé

Reputation: 1129

Resolved with minSdkVersion 24. Thank you @Anand

Upvotes: 40

Related Questions