Zbarcea Christian
Zbarcea Christian

Reputation: 9548

Android: application crashing because of firebase

Today I tested my app on a new device (see below) and I'm getting an exception right at launch. I can't event start the main activity.

Device: Genymotion Samsung Galaxy S2 - Android 4.1.1 - API 16

No google play services installed.

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.google.firebase.g
     at com.google.firebase.b.a(Unknown Source)
     at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
     at android.content.ContentProvider.attachInfo(ContentProvider.java:1058)
     at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
     at android.app.ActivityThread.installProvider(ActivityThread.java:4560)
     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190)
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132)
     at android.app.ActivityThread.access$1300(ActivityThread.java:130)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:137)
     at android.app.ActivityThread.main(ActivityThread.java:4745)
     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:786)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
     at dalvik.system.NativeStart.main(Native Method)

gradle build:

android {
   compileSdkVersion 23
   buildToolsVersion '23.0.2'
   useLibrary 'org.apache.http.legacy'

   defaultConfig {
     applicationId "com.app"
     minSdkVersion 10
     targetSdkVersion 21
     multiDexEnabled true
   }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }

    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
    compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
    compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
}

Is it crashing because of missing Play Services?

Note: I have implemented firebase about a month ago, and It's working on other devices.

Upvotes: 0

Views: 6680

Answers (4)

ahmed naeem
ahmed naeem

Reputation: 5

Add this line in the Application Tag on manifest file:

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

Upvotes: 0

Bob Snyder
Bob Snyder

Reputation: 38319

Although you have multiDexEnabled true in your build.gradle file, you are missing compile 'com.android.support:multidex:1.0.1' in your dependencies. I doubt that Mulidex is working. Review the Multidex configuration instructions and make sure you have done everything correctly.

Also, it is not good practice to include compile 'com.google.android.gms:play-services:9.4.0'. That adds all the Google Play and Firebase libraries to you app, increasing build time and the size of the APK file. Replace the dependency on play-services:9.4.0 with only the libraries you need. A list of the Google Play libraries is provided here, the Firebase libraries are listed here.

Upvotes: 2

jadeoti
jadeoti

Reputation: 58

Try adding this apply plugin: 'com.google.gms.google-services' to the end of your gradle build file

Upvotes: 1

JobiWon9178
JobiWon9178

Reputation: 89

You're correct, Firebase requires Google play services. As mentioned here in the release announcement for Google Play Services 9.0: Google Play Services 9.0

Firebase was built using Google Play services 9.0

Upvotes: 0

Related Questions