Getting Exception java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase

后端 未结 15 1494
渐次进展
渐次进展 2020-11-22 09:56

I have updated my application to the new firebase using the this and now when i compile my project i get the following exception.

Here is my logcat:

相关标签:
15条回答
  • 2020-11-22 10:19

    I solved by adding this and lowering the play-service dependancy to 8.4.0 compile 'com.google.android.gms:play-services:8.4.0'

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

    and add the following to the manifest

    android:name="android.support.multidex.MultiDexApplication"
    
    0 讨论(0)
  • 2020-11-22 10:19

    I think I've found a solution for this issue at this answer, please give it a look and thank @Gabriele Mariotti, he wrote:

    In your top-level build.gradle you have to add:

    buildscript {
        // ...
        dependencies {
            // ...
            classpath 'com.google.gms:google-services:3.0.0'
        }
    }
    

    Then in your module build.gradle:

    apply plugin: 'com.android.application'
    
    android {
      // ...
    }
    
    dependencies {
      // ... 
    
    }
    
    // ADD THIS AT THE BOTTOM
    apply plugin: 'com.google.gms.google-services'
    
    0 讨论(0)
  • 2020-11-22 10:21

    Downgrade your dependency in build.gradle file:

    from:

    compile 'com.google.android.gms:play-services:9.4.0'
    

    to:

    compile 'com.google.android.gms:play-services:7.3.0'
    

    This worked in my case, hope same for you.

    0 讨论(0)
  • 2020-11-22 10:23

    Step1: Fix multidex

    Application class:

    public class StudyNApplication extends Application {
    
        @Override
        public void onCreate() {
            super.onCreate();
            MultiDex.install(this);
        }
     }
    

    Grade file

    defaultConfig { 
    ...
    multiDexEnabled true
    }
    
    dependencies {
      compile 'com.android.support:multidex:1.0.0'
    }
    

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

    Remove

    compile 'com.google.android.gms:play-services:9.4.0'
    

    Add two lib:

    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.google.android.gms:play-services-location:9.4.0'
    

    It worked fine.

    0 讨论(0)
  • 2020-11-22 10:26

    Don't forget it.

    android:name="android.support.multidex.MultiDexApplication"
    
    0 讨论(0)
  • 2020-11-22 10:27

    This worked for me:

    1. If you haven't already, update your 'Google Play Services' to Revision 30 from Android SDK Manager > Extras.

    1. And then add the line compile 'com.android.support:multidex:1.0.1' to your dependancies (or simply remove multiDexEnabled true if not required)

    2. Add this attribute to the application tag in manifest: android:name="android.support.multidex.MultiDexApplication"
      If you already have a custom application class defined in Android Manifest, extend it from MultiDexApplication instead of Application

    Hope it helped!

    0 讨论(0)
提交回复
热议问题