java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions

前端 未结 12 915
野的像风
野的像风 2020-12-05 04:32

I was getting this weird error on my google developer console. So i used google Cloud Test Lab to See whats really happening. turns out my app is failing on almost all devic

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 05:00

    In Android 4.4 the solucion was similar like this(https://stackoverflow.com/a/38707231/3377472):

    -I have Google Play services revision 33

    1) Configure build.gradle and and dependencies

    Enabled multidex support and add library of multidex

       android {
            compileSdkVersion 23
            buildToolsVersion '23.0.3'
            defaultConfig {
                applicationId "packagename"
                minSdkVersion 14
                targetSdkVersion 23
                versionCode 1
                versionName "1.0"
    
                //------- Enabling multidex support----------.
                multiDexEnabled true
            }
    
            dexOptions {
                javaMaxHeapSize "3g"//use 3Gb of ram to launch android 
            }
    
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
            productFlavors {
            }
        }
    
    
    dependencies {
    
          compile 'com.android.support:multidex:1.0.1' // 1.0.0
    
          // if you are using google maps
          compile 'com.google.android.gms:play-services-maps:9.2.0'
          compile 'com.google.android.gms:play-services-location:9.2.0'
    }
    

    2)Edit Manifest, and add this android:name

    
    

    3)Application Class

    -My application class is:

    import android.support.multidex.MultiDex;
    
    public class Application extends AppCompatActivity {
    
    
        @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            //this is the solution 
            MultiDex.install(this);
    
            setContentView(R.layout.layout_example);
            ----
            ----
    

提交回复
热议问题