我第一次尝试使用FCM(之前没有GCM经验)。所以,我只是从quickstart-android-push-notifs复制代码并设置仪表板
当我从仪表板发送消息时,应用程序强制关闭,这里是相关文件
app level build.gradle dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.google.firebase:firebase-messaging:9.4.0'
}
日志:
08-22 22:59:38.360 12349-21221/com.rg.fcmsample E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
Process: com.rg.fcmsample, PID: 12349
java.lang.NoSuchMethodError: No static method zzz(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/data/com.rg.fcmsample/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.4.0_893226f39952d5ea4f5509d84b650028d7d5f6b4-classes.dex)
at com.google.android.gms.measurement.internal.zzx.zzbd(Unknown Source)
at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source)
at com.google.firebase.messaging.zzb.zzes(Unknown Source)
at com.google.firebase.messaging.zzb.zzc(Unknown Source)
at com.google.firebase.messaging.zzb.zzl(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.zzn(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.zzm(Unknown Source)
at com.google.firebase.iid.zzb$2.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
08-22 22:59:49.015 12349-21221/com.rg.fcmsample I/Process: Sending signal. PID: 12349 SIG: 9
08-22 23:00:10.549 21506-21506/com.rg.fcmsample W/System: ClassLoader referenced unknown path: /data/app/com.rg.fcmsample-2/lib/arm
08-22 23:00:10.764 21506-21506/com.rg.fcmsample W/System: ClassLoader referenced unknown path: /data/app/com.rg.fcmsample-2/lib/arm
08-22 23:00:10.799 21506-21506/com.rg.fcmsample D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
08-22 23:00:10.817 21506-21506/com.rg.fcmsample D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
08-22 23:00:10.887 21506-21506/com.rg.fcmsample E/FirebaseApp: Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5174)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4769)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4709)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.NoSuchMethodError: No static method zzz(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/data/com.rg.fcmsample/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.4.0_893226f39952d5ea4f5509d84b650028d7d5f6b4-classes.dex)
at com.google.android.gms.measurement.internal.zzx.zzbd(Unknown Source)
at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5174)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4769)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4709)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1415)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-22 23:00:10.889 21506-21506/com.rg.fcmsample I/FirebaseInitProvider: FirebaseApp initialization successful
出了什么问题?
答案 0 :(得分:4)
您应该在build.gradle
上插入此代码“编译”com.google.firebase:firebase-core:9.4.0'
我现在已经修好了。
答案 1 :(得分:3)
firebase-messaging和play-services必须是相同的版本:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.android.gms:play-services:10.2.0'
...
}
答案 2 :(得分:0)
您应该将compile 'com.google.firebase:firebase-core:9.6.1'
添加到您的bulid.gradle