firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 570 forks source link

Failed to transform firebase-auth-ktx-22.1.1.aar: Error while dexing #5322

Closed funkyidol closed 11 months ago

funkyidol commented 11 months ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3:

Upgrading to the latest Firebase BOM: 32.2.1+ throws the following error on build

 > Failed to transform firebase-auth-ktx-22.1.1.aar (com.google.firebase:firebase-auth-ktx:22.1.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=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /home/kshitij/.gradle/caches/transforms-3/0960a29be8c84d6653dd22363a0e6a88/transformed/firebase-auth-ktx-22.1.1-runtime.jar.
         > Error while dexing.

This error is thrown for every module which has the firebase auth dependency in the build.gradle. Downgrading to Firebase BOM 32.2.0 fixes the issue.

Steps to reproduce:

Happens everytime on compile

Relevant Code:

Code from build.gradle of one of the modules

api platform("com.google.firebase:firebase-bom:$firebase_bom")
    api 'com.google.firebase:firebase-auth-ktx'
    api 'com.google.firebase:firebase-database-ktx'
    api 'com.google.firebase:firebase-firestore-ktx'
    api 'com.google.firebase:firebase-config-ktx'
    api 'com.google.firebase:firebase-analytics'
google-oss-bot commented 11 months ago

I found a few problems with this issue:

argzdev commented 11 months ago

Hi @funkyidol, thanks for reaching out. I've tried reproducing this behavior on the latest version of BoM 32.3.0 and also the version you've mentioned 32.2.1 but these versions seems to compile correctly, and I was able to run the app on an emulator. That said, it could be a minor compilation corruption error. Could you try cleaning and rebuilding your project and see if that makes any difference?

funkyidol commented 11 months ago

Hi @argzdev , that was my first thought so I tried both clean and build as well as 'invalidate & restart'.

Is there some more data I can share with you to help reproduce or help pinpoint the issue ?

argzdev commented 11 months ago

That's odd, can you share a minimal reproducible example? Maybe there's a project configuration that I'm missing.

funkyidol commented 11 months ago

Im experiencing the same issue with Firebase BOM 32.3.1. If it helps this is my gradle variables list. Is the issue because of my Kotlin and AGP version ?


buildscript {
    ext.kotlin_version = '1.8.20'
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7' //Sticking to this old version as of 5/5/23 due to native symbol upload issue
        classpath "io.realm:realm-gradle-plugin:10.16.1"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0"
        classpath 'org.ajoberstar.grgit:grgit-core:5.0.0'
//        classpath 'com.google.firebase:firebase-appdistribution-gradle:2.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "io.sentry.android.gradle" version "2.1.4"
}

allprojects {
    ext.app_version = "3.2.4"

    ext.compile_sdk = 34
    ext.build_tools = "34"
    ext.min_sdk = 21
    ext.target_sdk = 33

    ext.camerax_version = '1.3.0-rc01'
    ext.mlkit_face_detection = '17.1.0'
    ext.mlkit_barcode_scan = '18.3.0'
    ext.mlkit_text_recognition = '16.0.0'
    ext.mlkit_language_id = '17.0.4'
    ext.kotlinx_integration = '1.7.3'
    ext.revenuecat = '5.6.4'
    ext.koin = '3.4.3'
    ext.koin_compose = '3.4.6'
    ext.constraint_layout = '2.1.4'
    ext.coroutine_core = '1.7.3'
    ext.nav_version = '2.7.2'
    ext.androidx_lifecycle = '2.6.2'
    ext.activity_ktx = '1.7.2'
    ext.fragment_ktx = '1.6.1'
    ext.material = '1.9.0'
    ext.mixpanel = '7.3.2'
    ext.androidx_browser = '1.6.0'
    ext.firebase_bom = '32.3.1'
    ext.core_ktx = '1.12.0'
    ext.appcompat = '1.6.1'
    ext.aws = '2.73.0'
    ext.room_version = '2.5.2'
    ext.recyclerview = '1.3.1'
    ext.sentry = '6.28.0'
    ext.timber = '5.0.1'
    ext.okhttp = '4.11.0'
    ext.moshi = '1.15.0'
    ext.compose = '2023.09.00'
    ext.viewmodel_compose = '2.6.2'
    ext.junit = '4.13.2'
    ext.ext_junit = '1.1.5'
    ext.espresso_core = '3.5.1'
    ext.preference_ktx = '1.2.1'

    repositories {
        google()
        maven { url 'https://maven.google.com/' }
        mavenCentral()
        maven { url "https://jitpack.io" }
    }

}
funkyidol commented 11 months ago

After updating the Gradle plugin, the issue seems to be resolved.

buildscript {
    ext.kotlin_version = '1.8.22'
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7' //Sticking to this old version as of 5/5/23 due to native symbol upload issue
//        classpath "io.realm:realm-gradle-plugin:10.16.1"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0"
        classpath 'org.ajoberstar.grgit:grgit-core:5.0.0'
//        classpath 'com.google.firebase:firebase-appdistribution-gradle:2.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "io.sentry.android.gradle" version "2.1.4"
    id 'io.realm.kotlin' version '1.10.2' apply false
    id 'com.google.devtools.ksp' version '1.8.22-1.0.11' apply false
}

allprojects {
    ext.app_version = "3.2.4"

    ext.compile_sdk = 34
    ext.build_tools = "34"
    ext.min_sdk = 21
    ext.target_sdk = 33

    ext.camerax_version = '1.3.0-rc01'
    ext.mlkit_face_detection = '17.1.0'
    ext.mlkit_barcode_scan = '18.3.0'
    ext.mlkit_text_recognition = '16.0.0'
    ext.mlkit_language_id = '17.0.4'
    ext.kotlinx_integration = '1.7.3'
    ext.revenuecat = '5.6.4'
    ext.koin = '3.5.0'
    ext.koin_compose = '3.5.0'
    ext.constraint_layout = '2.1.4'
    ext.coroutine_core = '1.7.3'
    ext.nav_version = '2.7.2'
    ext.androidx_lifecycle = '2.6.2'
    ext.activity_ktx = '1.7.2'
    ext.fragment_ktx = '1.6.1'
    ext.material = '1.9.0'
    ext.mixpanel = '7.3.2'
    ext.androidx_browser = '1.6.0'
    ext.firebase_bom = '32.3.1'
    ext.core_ktx = '1.12.0'
    ext.appcompat = '1.6.1'
    ext.aws = '2.73.0'
    ext.room_version = '2.5.2'
    ext.recyclerview = '1.3.1'
    ext.sentry = '6.28.0'
    ext.timber = '5.0.1'
    ext.okhttp = '4.11.0'
    ext.moshi = '1.15.0'
    ext.compose = '2023.09.00'
    ext.viewmodel_compose = '2.6.2'
    ext.realm = '1.10.2'
    ext.junit = '4.13.2'
    ext.ext_junit = '1.1.5'
    ext.espresso_core = '3.5.1'
    ext.preference_ktx = '1.2.1'

    repositories {
        google()
        maven { url 'https://maven.google.com/' }
        mavenCentral()
        maven { url "https://jitpack.io" }
    }

}

So it would be great if this could be documented somewhere.

argzdev commented 11 months ago

Hi @funkyidol, I'm glad you were able to resolve your issue. That said, I'm unable to reproduce the same behavior you're experiencing even with the version you've mentioned 1.8.22. I do think the problem you're experiencing is definitely due to the compatibility matrix and not specific to Firebase. If you'd like to learn more, you can check out the compatibility matrix of Kotlin and Gradle here. You may also check out the documentation regarding the AGP and gradle compatibility.

I'll close this ticket for now. Feel free to come back here if you have any other questions. Thanks!

fisforfaheem commented 11 months ago

Just updated the min sdk to version 24 and issue was resolved

maestrovsmaster commented 10 months ago

i have the same problem just added a dependency ### implementation 'com.google.firebase:firebase-auth-ktx': Could not resolve all files for configuration ':presentation:detachedConfiguration63'.

Failed to transform jetified-firebase-auth-ktx-22.1.1-runtime.jar to match attributes {artifactType=ext-dex-dexBuilderDevDebug, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for DexingExternalLibArtifactTransform: /.gradle/caches/transforms-3/774d44c446ce3832a2a5ecf5d224df16/transformed/jetified-firebase-auth-ktx-22.1.1-runtime.jar. Error while dexing.

My gradle:

    implementation(platform("com.google.firebase:firebase-bom:32.2.2"))
    implementation 'com.google.firebase:firebase-firestore-ktx'
    implementation 'com.google.firebase:firebase-storage-ktx'
     implementation 'com.google.firebase:firebase-auth-ktx'  // <== This is problematic dependency
    implementation 'com.google.firebase:firebase-messaging-ktx'
  androidBuildToolsVersion = "33.0.0"
  androidMinSdkVersion = 24
  androidTargetSdkVersion = 33
  androidCompileSdkVersion = 33
  ext {
    kotlin_version = '1.8.22' //1.3.72
  }
  repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:7.4.2'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    classpath 'io.fabric.tools:gradle:1.28.0'
    classpath 'com.google.gms:google-services:4.3.15'

Java 8

Android Studio Giraffe | 2022.3.1 Canary 6 Build #AI-223.8214.52.2231.9615888, built on February 16, 2023 Runtime version: 17.0.6+0-17.0.6b802.4-9586694 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.7.10

I attempted use difference versions of com.google.firebase:firebase-auth-ktx', alse i've changed kotlin plugin versions. Error the same...

Please help, I've been stuck with this problem for a few days now.