LS_
LS_

Reputation: 7129

java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions on Android API 15

I have an app that has as minSdkVersion API 14, I've tested the app on a device running Android M and everything works fine, then I've tried to run the app on a device running API 15 (Android 4.0.3) and I get the following crash when the app starts:

FATAL EXCEPTION: main 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:986)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
at android.app.ActivityThread.installProvider(ActivityThread.java:4249) 
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4004) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3958)
at android.app.ActivityThread.access$1300(ActivityThread.java:127) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

I'm not using Firebase in my app and this is my gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "it.*.*"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile project(':libraries:Sliding Menu')
    compile 'com.android.volley:volley:1.0.0'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile 'com.android.support:cardview-v7:23.+'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services-analytics:9.0.0'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'

Does anyone know what could be the problem? Why is it crashing only on the device with API 15?

Upvotes: 0

Views: 6589

Answers (3)

Unnikrishnan M R
Unnikrishnan M R

Reputation: 224

According to latest Google docs, Firebase is the new version of Google Cloud Messaging. From your gradle file it seems you are adding all the play services hence firebase is also added. Replace

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

with the only the libraries that you need. For more information on selective services refer this link

Upvotes: 1

Chintan Soni
Chintan Soni

Reputation: 25267

I don't think you require google-play-services for using firebase

What I have in my gradles:

build.gradle(Project):

...
dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
...

build.gradle:(Module)

...
dependencies {
       ...
       compile 'com.google.firebase:firebase-messaging:9.0.2'
    }
...
apply plugin: 'com.google.gms.google-services'

Check this way and tell me whether it works or not.

Note: If you want to use Firebase Analytics, then you will require

compile 'com.google.firebase:firebase-analytics:9.0.0'

in your build.gradle(Module).

Upvotes: 0

Abdullah
Abdullah

Reputation: 965

If you haven't already, update your 'Google Play Services' to Revision 30 from Android SDK

If you haven't already add this attribute to the application tag in manifest: android:name="android.support.multidex.MultiDexApplication"

As you have stated "I'm not using Firebase in my app" remove all the improts of Firebase related class and then run gradlew clean from terminal in android studio.

Upvotes: 0

Related Questions