Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Didn't find class "com.google.firebase.provider.FirebaseInitProvider"

Before, my program run well. But When I just updated my Android studio to the latest version (2.2 built on 15-sept-16), I am having the following error. When I built it, it says: Built sucessfully, but this error appears when I run my program:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.androidtutorial, PID: 28293 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.example.androidtutorial-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.androidtutorial-2/lib/x86, /system/lib, /vendor/lib]] at android.app.ActivityThread.installProvider(ActivityThread.java:5814) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.androidtutorial-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.androidtutorial-2/lib/x86, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.ActivityThread.installProvider(ActivityThread.java:5799) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342)  at android.app.ActivityThread.-wrap2(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

I already looked at other questions but the problem is not the same. What am I doing wrong? Please help

like image 939
TSR Avatar asked Oct 01 '16 23:10

TSR


2 Answers

It seems you have a problem with Over 64K Methods and then tried to resolved it with multiDexEnabled true in build.gradle (app module). But you need to add more than:

  1. add: compile 'com.android.support:multidex:1.0.0' in dependencies of build.gradle

  2. Extends your Application class to MultiDexApplication. and add MultiDex.install(this); in onCreated method of Application class.

your issue should be resolved

refer link: https://developer.android.com/studio/build/multidex.html

like image 166
Chi Minh Trinh Avatar answered Oct 26 '22 23:10

Chi Minh Trinh


In app module build.gradle

android {
   ...
   defaultConfig {
      multiDexEnabled true
      ...
   }
}

dependencies {
  // add dependency 
  compile 'com.android.support:multidex:1.0.1'
}

Change name in AndroidManifest.xml

<application
   ....
  android:name=".MyApplication">

 // ...
</application>

Crate a MyApplication.java file

public class MyApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}

For MORE details can see this link.

like image 33
Garg's Avatar answered Oct 27 '22 01:10

Garg's