Firebase消息传递NoSuchMethodError.zzUrexception

我正在尝试将FCM集成到Android项目中,因为它是用Firebase文档编写的。

我的应用程序的gradle:

dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' ... compile 'com.android.support:multidex:1.0.0' compile 'com.android.support:support-v4:20.0.0' compile 'com.google.firebase:firebase-core:9.2.0' compile 'com.google.firebase:firebase-config:9.2.0' compile 'com.google.firebase:firebase-messaging:9.0.2' compile 'com.google.firebase:firebase-crash:9.2.0' compile 'com.google.android.gms:play-services-ads:9.2.0' compile 'com.google.android.gms:play-services-analytics:9.2.0' compile 'com.google.android.gms:play-services-games:9.2.0' } apply plugin: 'com.google.gms.google-services' 

的Manifest.xml:

 <service android:name=".MyFirebaseMessagingService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> 

和MyFirebaseMesagingService:

 public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { Log.i("info", "From: " + remoteMessage.getFrom()); Log.i("info", "Notification Message Body: " + remoteMessage.getNotification().getBody()); } 

}

但是当我发送推,我得到的是:

 java.lang.NoSuchMethodError: com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.zzUr at com.google.firebase.messaging.FirebaseMessagingService.zzz(Unknown Source) at com.google.firebase.iid.zzb.onStartCommand(Unknown Source) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2805) at android.app.ActivityThread.access$1900(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5299) 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:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) 

不能谷歌它。 有没有人遇到它?

  • 与Facebook的FirebaseUI身份validation不起作用
  • 当应用程序在后台时,FCM推送通知显示白色方形图标而不是应用程序图标
  • 在更新到新的Firebase之后获取Exception java.lang.NoClassDefFoundError:com.google.firebase.FirebaseOptions
  • 使用firebase作业调度程序安排定期作业
  • 发送一个通知后未注册的令牌错误
  • 在Android上使用Firebase Analytics时出现SERVICE_VERSION_UPDATE_REQUIRED错误
  • 如何从代码中禁用Firebase项目的用户帐户?
  • Firebase(FCM)如何获取令牌
  • 尝试运行相同版本的所有服务。 在这种情况下,更改:

     compile 'com.google.firebase:firebase-messaging:9.0.2' 

     compile 'com.google.firebase:firebase-messaging:9.2.0' 

    并检查是否发生相同的问题。

    更改firebase1的版本它适用于我!

    版本必须相同:

     compile 'com.google.firebase:firebase-analytics:9.2.0' compile 'com.google.firebase:firebase-messaging:9.2.0' compile 'com.google.firebase:firebase-core:9.2.0' 

    我面临同样的问题,通过正确configurationproguard规则来解决这个问题。

    我在这里做了如下:

    首先,我已经在proguard-rules.pro中排除了像这样混淆谷歌类:

     -keep public class com.google.** {*;} 

    其次,我已经在build.gradle中启用了这个minifyEnabled,像这样:

      apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.e2e.quiz" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled true 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.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.squareup.picasso:picasso:2.4.0' compile 'com.google.android.gms:play-services-gcm:9.2.1' compile 'com.google.android.gms:play-services-analytics:9.2.1' compile 'com.google.android.gms:play-services-ads:9.2.1' compile project(':ast-dst') 

    }

    通过更改构buildgradle中的firebase-messaging库版本,保留相同版本的firebase-core库和firebase-messaging库

    从:

     compile 'com.google.firebase:firebase-core:9.2.0' compile 'com.google.firebase:firebase-messaging:9.0.2 

    至:

     compile 'com.google.firebase:firebase-core:9.2.0' compile 'com.google.firebase:firebase-messaging:9.2.0'