NoClassDefFoundError: com.google.firebase.FirebaseOptions

前端 未结 4 2721
有刺的猬
有刺的猬 2021-02-20 16:26

I keep on getting the NoClassDefFoundError on other test device (4.4.2) that I\'m using. But works fine on my test device (Android 5.1).

I tried the solutio

4条回答
  •  广开言路
    2021-02-20 17:14

    Thanks to TapanHP above I got this working quickly for me:

    Short Answer:

    I had multiDexEnabled= true set in my app/build.gradle file and this ran fine on Android 5.x.x above but any test device with 4.x.x (kit kat) would throw a critical error "Unfortunately, YourAppName has stopped."

    Debugger showed:

    Could not find class 'com.google.firebase.FirebaseOptions' ....
    

    Note: I also have a custom class that extends Application.

    My Solution: Added the following code to my custom Application class

    import android.support.multidex.MultiDex;
    public class YourCustomApplication extends Application {
    
        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    
    ...
    } 
    

    No more critical crash.

提交回复
热议问题