Getting Exception java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase
This worked for me:
- If you haven't already, update your 'Google Play Services' to Revision 30 from Android SDK Manager > Extras.
And then add the line
compile 'com.android.support:multidex:1.0.1'
to your dependancies (or simply removemultiDexEnabled true
if not required)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 fromMultiDexApplication
instead ofApplication
Hope it helped!
Using latest Google Play services but was not working. For me this procedure is working:
Updated my Application class:
public class App extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }
Updated
build.gradle
file:defaultConfig { ... multiDexEnabled true }
Included dependencies:
dependencies { compile 'com.android.support:multidex:1.0.0' }
It is so simple to fix guys.If you are using player-services and firebase both in your project make sure that you don't import all the available services in the google.Just import the APIs what you actually need. For example:
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.android.gms:play-services:9.2.0'
Doing this way it can give you noclassdeffounderror .To fix this
remove play-services and sync your project. If you have dependency like using ads or maps in your app then define the specific API. like:
compile 'com.google.android.gms:play-services-maps:9.2.0'
Note: Maximum don't try to use multiDexEnabled true. This should be your last step to fix something.
Hope this is helpful.