firebase / firebase-android-sdk

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

Crash after updating firebase auth sdk to version 22.0.0 #4981

Closed Surkhojb closed 1 year ago

Surkhojb commented 1 year 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: Describe the problem

As per this issue https://github.com/firebase/firebase-android-sdk/issues/4836. I wanted to update the firebase authentication library to the latest version that suppose to remove the support for SafetyNet library (https://firebase.google.com/support/release-notes/android#auth_v22-0-0)

Steps to reproduce:

Update the latest version of firebase auth to com.google.firebase:firebase-auth:22.0.0. After doing that and try to open the app the app will crash over and over on the first launch.

Relevant Code:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/appcheck/interop/InternalAppCheckTokenProvider;
                                                                                                        at com.google.firebase.firestore.FirestoreRegistrar.getComponents(FirestoreRegistrar.java:54)
                                                                                                        at com.google.firebase.tracing.ComponentMonitor.processRegistrar(ComponentMonitor.java:28)
                                                                                                        at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:117)
                                                                                                        at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:99)
                                                                                                        at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:46)
                                                                                                        at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:387)
                                                                                                        at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:438)
                                                                                                        at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:295)
                                                                                                        at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:263)
                                                                                                        at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:248)
                                                                                                        at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:69)
                                                                                                        at android.content.ContentProvider.attachInfo(ContentProvider.java:2516)
                                                                                                        at android.content.ContentProvider.attachInfo(ContentProvider.java:2486)
                                                                                                        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:61)
                                                                                                        at android.app.ActivityThread.installProvider(ActivityThread.java:8308)
                                                                                                        at android.app.ActivityThread.installContentProviders(ActivityThread.java:7810)
                                                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7564)
                                                                                                        at android.app.ActivityThread.access$1700(ActivityThread.java:315)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2286)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8751)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
                                                                                                    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider"
google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

argzdev commented 1 year ago

Hey, @Surkhojb, thanks for reaching out. Testing Firebase Auth version 22.0.0 with our quickstarts seems to work just fine. Any chance you could you share with me a minimal reproducible example of your issue? It'll help speed up our investigation. Thanks!

GrandeSamarone commented 1 year ago

Hi, I have the same problem, did anyone manage to solve it?

android { compileSdkVersion 33 ndkVersion flutter.ndkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    applicationId "com.example.app_mtboyfogaca"
    minSdkVersion 20
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true

}

buildTypes {
    release {
        signingConfig signingConfigs.debug
    }
}
namespace 'com.example.app_mtboyfogaca'

}

flutter { source '../..' apply plugin: 'com.google.firebase.crashlytics' }

dependencies { implementation platform('com.google.firebase:firebase-bom:30.3.2') implementation 'com.google.firebase:firebase-messaging:23.1.2' implementation 'com.google.firebase:firebase-crashlytics:18.3.7' implementation 'com.google.android.gms:play-services-safetynet:18.0.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-auth:22.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.9.0'

def core_version = "1.6.0"
def work_version = "2.7.1"

implementation 'com.google.code.gson:gson:2.9.1'
implementation "androidx.core:core:$core_version"
// (Java only)
implementation "androidx.work:work-runtime:$work_version"
implementation ('io.socket:socket.io-client:2.1.0') {
    exclude group: 'org.json', module: 'json'
}
implementation 'com.google.guava:guava:27.0.1-android'

}

einare commented 1 year ago

I am no specialist. But after serveral hours of reading, I stumble on the android SDK released notes, I noticed by updating auth to 22.0.0 The Firebase-bom is suppose to be 32.0.0. So I changed that to 32.0.0 even thou it wasn´t highlighted in the build.gradle file. The app started to work.

GrandeSamarone commented 1 year ago

Eu não sou nenhum especialista. Mas depois de várias horas de leitura, tropeço nas notas lançadas do Android SDK, notei atualizando a autenticação para 22.0.0 O Firebase-bom deve ser 32.0.0. Então mudei para 32.0.0 mesmo que não tenha sido destacado no arquivo build.gradle. O aplicativo começou a funcionar.

Good morning, and which JavaVersion are you using? mine also has a problem like this

Could not resolve com.android.tools.build:gradle:7.4.2. Required by: project:

No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:

GrandeSamarone commented 1 year ago

Eu não sou nenhum especialista. Mas depois de várias horas de leitura, tropeço nas notas lançadas do Android SDK, notei atualizando a autenticação para 22.0.0 O Firebase-bom deve ser 32.0.0. Então mudei para 32.0.0 mesmo que não tenha sido destacado no arquivo build.gradle. O aplicativo começou a funcionar.

this worked for me i switched to firebase-well it should be 32.0.0 and java in gladle is 17 thank you I've been trying to solve it for days

Surkhojb commented 1 year ago

Hi @argzdev.

Here is the way we have our project configuration now:

Here is the build configuration for our project:

    const val compileSdk = 33
    const val buildToolsVersion = "32.0.0"
    const val minSdk = 21
    const val targetSdk = 33
    const val javaVersion = "1.8"

We are making use of buildSrc to handle our dependencies, for firebase this is our current configuration :

object Firebase {
    // Firebase (https://firebase.google.com/support/release-notes/android)
    const val auth = "com.google.firebase:firebase-auth:21.1.0"
    const val config = "com.google.firebase:firebase-config:21.2.1"
    const val analytics = "com.google.firebase:firebase-analytics:21.2.0"
    const val database = "com.google.firebase:firebase-database:20.1.0"
    const val messaging = "com.google.firebase:firebase-messaging:23.1.1"
    const val functions = "com.google.firebase:firebase-functions:20.2.2"
    const val firestore = "com.google.firebase:firebase-firestore:24.4.2"
    const val dynamimLinks = "com.google.firebase:firebase-dynamic-links:21.1.0"
    const val inAppMessaging = "com.google.firebase:firebase-inappmessaging-display:20.3.0"
    const val crashlytics = "com.google.firebase:firebase-crashlytics:18.3.2"
}

In our app build.gradle we have them include ( we are using multimodule project):

// Firebase Dependencies
    implementation(Firebase.auth)
    implementation(Firebase.config)
    implementation(Firebase.analytics)
    implementation(Firebase.database)
    implementation(Firebase.messaging)
    implementation(Firebase.functions)
    implementation(Firebase.firestore)
    implementation(Firebase.dynamimLinks)
    implementation(Firebase.inAppMessaging)
    implementation(Firebase.crashlytics)

In our build.gradle base module that containts the class to handle login with different providers we also include these dependencies:

"implementation"(Firebase.auth)
    "implementation"(Firebase.analytics)
    "implementation"(Firebase.database)
    "implementation"(Firebase.messaging)
    "implementation"(Firebase.functions)
    "implementation"(Firebase.dynamimLinks)
    "implementation"(Firebase.inAppMessaging)

@argzdev Note that if we make use of version 21.2.0 everything still working but the moment we change it to 22.0.0 is when the app crash the moment we want to launch it.

Thanks!

GrandeSamarone commented 1 year ago

Oi@argzdev.

Aqui está a maneira como temos nossa configuração de projeto agora:

Aqui está a configuração de compilação para o nosso projeto:

    const val compileSdk = 33
    const val buildToolsVersion = "32.0.0"
    const val minSdk = 21
    const val targetSdk = 33
    const val javaVersion = "1.8"

Estamos usando buildSrcpara lidar com nossas dependências, para firebase esta é nossa configuração atual:

object Firebase {
    // Firebase (https://firebase.google.com/support/release-notes/android)
    const val auth = "com.google.firebase:firebase-auth:21.1.0"
    const val config = "com.google.firebase:firebase-config:21.2.1"
    const val analytics = "com.google.firebase:firebase-analytics:21.2.0"
    const val database = "com.google.firebase:firebase-database:20.1.0"
    const val messaging = "com.google.firebase:firebase-messaging:23.1.1"
    const val functions = "com.google.firebase:firebase-functions:20.2.2"
    const val firestore = "com.google.firebase:firebase-firestore:24.4.2"
    const val dynamimLinks = "com.google.firebase:firebase-dynamic-links:21.1.0"
    const val inAppMessaging = "com.google.firebase:firebase-inappmessaging-display:20.3.0"
    const val crashlytics = "com.google.firebase:firebase-crashlytics:18.3.2"
}

Em nosso aplicativo build.gradle, incluímos (estamos usando um projeto multimódulo):

// Firebase Dependencies
    implementation(Firebase.auth)
    implementation(Firebase.config)
    implementation(Firebase.analytics)
    implementation(Firebase.database)
    implementation(Firebase.messaging)
    implementation(Firebase.functions)
    implementation(Firebase.firestore)
    implementation(Firebase.dynamimLinks)
    implementation(Firebase.inAppMessaging)
    implementation(Firebase.crashlytics)

Em nosso build.gradlemódulo base que contém a classe para tratar o login com diferentes provedores também incluímos estas dependências:

"implementation"(Firebase.auth)
    "implementation"(Firebase.analytics)
    "implementation"(Firebase.database)
    "implementation"(Firebase.messaging)
    "implementation"(Firebase.functions)
    "implementation"(Firebase.dynamimLinks)
    "implementation"(Firebase.inAppMessaging)

@argzdevObserve que, se usarmos a versão, 21.2.0tudo ainda funcionará, mas no momento em que a alterarmos, 22.0.0 o aplicativo falhará no momento em que desejamos iniciá-lo.

Obrigado!

implementation platform('com.google.firebase:firebase-bom:32.0.0')

eu nao vi isso no seu código

argzdev commented 1 year ago

Hey @Surkhojb, thanks for the extra details. If you only update the Auth library, the common library being used in other Firebase products (in this case Firestore) is being changed. As a result, this may cause issues such as NoClassDefFoundError. To fix this, you need to update your Firestore version to the latest version 24.6.0 when you update your Firebase Auth to 22.0.0.

I recommend using Firebase BoM (Bill of Material) to guarantee the working version of each Firebase product with each other. You may check out our documentations how to utilize this.

Your updated buildSrc with BoM, will look like this:

object Firebase {
    // Firebase (https://firebase.google.com/support/release-notes/android)
    const val bom = "com.google.firebase:firebase-bom:32.0.0"
    const val auth = "com.google.firebase:firebase-auth"
    const val config = "com.google.firebase:firebase-config"
    const val analytics = "com.google.firebase:firebase-analytics"
    const val database = "com.google.firebase:firebase-database"
    const val messaging = "com.google.firebase:firebase-messaging"
    const val functions = "com.google.firebase:firebase-functions"
    const val firestore = "com.google.firebase:firebase-firestore"
    const val dynamimLinks = "com.google.firebase:firebase-dynamic-links"
    const val inAppMessaging = "com.google.firebase:firebase-inappmessaging-display"
    const val crashlytics = "com.google.firebase:firebase-crashlytics"
}

dependencies:

implementation(platform(Firebase.bom))
    implementation(Firebase.auth)
    implementation(Firebase.config)
    implementation(Firebase.analytics)
    implementation(Firebase.database)
    implementation(Firebase.messaging)
    implementation(Firebase.functions)
    implementation(Firebase.firestore)
    implementation(Firebase.dynamimLinks)
    implementation(Firebase.inAppMessaging)
    implementation(Firebase.crashlytics)

That said, since this issue has been resolved. I'll close this now. Feel free to ask this to be reopened if you think this is a mistake or there are further issues with our SDK. Thanks!