在Android 8+上收到来自Firebase的推送时,应用崩溃

时间:2018-06-19 13:48:13

标签: java android firebase push-notification

我最近遇到了以下问题:在Android 8及更高版本的设备上收到推送通知时,应用程序崩溃。

这是堆栈跟踪:

#0. Crashed: main
       at com.google.firebase.iid.zzh.void onServiceConnected(android.content.ComponentName,android.os.IBinder)(Unknown Source:4)
       at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1652)
       at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1681)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

--

Fatal Exception: java.lang.ClassCastException: android.app.job.JobServiceEngine$JobInterface cannot be cast to com.google.firebase.iid.zzf
       at com.google.firebase.iid.zzh.void onServiceConnected(android.content.ComponentName,android.os.IBinder)(Unknown Source:4)
       at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1652)
       at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1681)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

这些是库版本:

 //Google services
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true;
}

我试图降级Firebase,直到有必要降级Google服务的版本-它没有帮助。

该项目使用推送服务提供商(infobip )的第三方库,很可能是其中的问题。

有人对此有想法吗?

1 个答案:

答案 0 :(得分:0)

尝试基于this link更新最新版本的依赖关系,并添加 firebase消息

    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.google.firebase:firebase-analytics:16.0.3'
    implementation 'com.google.firebase:firebase-appindexing:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    implementation 'com.google.firebase:firebase-functions:16.1.0'
    implementation 'com.google.firebase:firebase-messaging:17.3.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-crash:16.2.0'
    implementation 'com.google.firebase:firebase-invites:16.0.3'
    implementation 'com.google.firebase:firebase-perf:16.1.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-config:16.0.0'

并确保您在项目级别的构建脚本如下:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

此外,如果您有播放服务,请确保您根据this link更新:

implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'