androidlocalytics

android localytics 4.5.1 crash NoClassDefFoundError com.localytics.android.BackgroundService


I updated my localytics from 4.2 to 4.5.
I updated my firebase to the latest ver also 11.6.0.
I am using gradle:

compile 'com.google.android.gms:play-services-ads:11.6.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.localytics.android:library:4.5.1'
compile 'com.android.support:appcompat-v7:26.1.0'

Unfortunately the app is crashing at launch time with this trace:

java.lang.NoClassDefFoundError: com.localytics.android.BackgroundService
 at com.localytics.android.ManifestHandler.cancelBackgroundTask(ManifestHandler.java:180)
 at com.localytics.android.ManifestHandler._onUploadCompleted(ManifestHandler.java:162)
 at com.localytics.android.BaseHandler._uploadCallback(BaseHandler.java:326)
 at com.localytics.android.BaseHandler$3.run(BaseHandler.java:129)
 at com.localytics.android.BaseProvider.runBatchTransaction(BaseProvider.java:403)
 at com.localytics.android.BaseHandler._runBatchTransactionOnProvider(BaseHandler.java:154)
 at com.localytics.android.BaseHandler.handleMessage(BaseHandler.java:125)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.os.HandlerThread.run(HandlerThread.java:61)

I have no idea how to fix this (besides reverting to the older version).


Solution

  • Track what is missing and add it. In my case it was gcm dependency.

    implementation "com.google.android.gms:play-services-gcm:11.6.2"
    

    You can also try upgrade your support library versions and buildToolsVersion to latest version.