2

I am trying to implement Fire Base in my application. Its working fine in Lollipop and above.

While running pre lollipop am getting an error:

java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4825)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4420)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4360)
at android.app.ActivityThread.access$1500(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5052)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)

In my Gradle:

defaultConfig {
    applicationId "com.manoramaonline.mmc.year2017"
    minSdkVersion 14
    targetSdkVersion 23
    multiDexEnabled true
}
dependencies {
    compile project(':library')
    compile project(':wheel')
    compile project(':socialauthandroid')
    compile project(':ambilWarna')
    compile files('libs/acra-4.5.0.jar')
    compile files('libs/FlurryAgent.jar')
    compile files('libs/poi-3.9.jar')
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
    compile files('libs/InMobi-5.3.1.jar')
    compile 'com.android.support:cardview-v7:23.3.+'
    compile 'com.android.support:recyclerview-v7:23.3.+'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.googlecode.json-simple:json-simple:1.1'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
}

I trying by add MultiDex as dependency and enable it in default config. But not fix the solution.

I think issue is 64k reference limit

But don't know how to fix it.

Nurjan
  • 5,889
  • 5
  • 34
  • 54
Binil Surendran
  • 2,524
  • 6
  • 35
  • 58
  • 1
    Possible duplicate of [Getting Exception java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase](http://stackoverflow.com/questions/37360126/getting-exception-java-lang-noclassdeffounderror-com-google-firebase-firebaseop) – Abbas Oct 31 '16 at 09:10
  • If you have correctly configured Multidex, you will see this message in your logcat output `I/MultiDex: install done`. Do you see that message? If not, review the [instructions for enabling Multidex](https://developer.android.com/studio/build/multidex.html#mdex-gradle) including the changes to your manifest. – Bob Snyder Oct 31 '16 at 13:54

2 Answers2

3

I too had the same issue, I just downgraded the google play-service dependency to compile 'com.google.android.gms:play-services:8.4.0' and the problem gets solved.

Amit Upadhyay
  • 7,179
  • 4
  • 43
  • 57
1

I also had the same issue on pre-lollipop devices , i think u forgot to add

android:name="android.support.multidex.MultiDexApplication">

inside < application > tag in manifest.

Example

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>
Mr Robot
  • 1,747
  • 6
  • 35
  • 67