Home » Android » android – Unable to get provider com.google.firebase.provider.FirebaseInitProvider in 2020-Exceptionshub

android – Unable to get provider com.google.firebase.provider.FirebaseInitProvider in 2020-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

I made this same question a few days ago, and a few told that the answer could be in this other question Didn't find class "com.google.firebase.provider.FirebaseInitProvider"?, or in this one Unable to get provider com.google.firebase.provider.FirebaseInitProvider. But the truth is that none of those helped me. First of all, those are 3 year old questions and most of the accepted answers are too, since the launch of AndroidX a ton of things have changed. Second, in those other questions most of the solutions are to apply multidex (https://developer.android.com/studio/build/multidex) but they are using minSdkVersion of below 20, that is why they need to apply multidex since it is required if you are using API 20 or below, according to the official documentation I linked above. BUT my project is using minSdkVersion 23, so again, according to the documentation “If your minSdkVersion is set to 21 or higher, multidex is enabled by default and you do not need the multidex support library.” So I really do not know what I have to do, any ideas?

This is the Logcat and the app.gradle file

2020-02-17 01:33:43.871 5975-5975/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.Interactive.textmefriends, PID: 5975
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.Interactive.textmefriends-e44Txln6Z1Rx80v1hUODRQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.Interactive.textmefriends-e44Txln6Z1Rx80v1hUODRQ==/lib/x86, /system/lib, /vendor/lib]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:6288)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.Interactive.textmefriends-e44Txln6Z1Rx80v1hUODRQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.Interactive.textmefriends-e44Txln6Z1Rx80v1hUODRQ==/lib/x86, /system/lib, /vendor/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6273)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772) 
    at android.app.ActivityThread.-wrap1(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
    at android.os.Handler.dispatchMessage(Handler.java:105) 
    at android.os.Looper.loop(Looper.java:164) 
    at android.app.ActivityThread.main(ActivityThread.java:6541) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

build.gradle module:app

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.Interactive.textmefriends"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'

    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-database:19.2.1'
    //implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'

    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'

    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation "androidx.fragment:fragment:1.2.1"
    implementation 'com.google.firebase:firebase-ads:18.3.0'

    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'com.google.firebase:firebase-firestore:21.4.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
How to&Answers: