使用FirebaseMessagingService类时出现错误"返回类型int与Intent不兼容"

5 android firebase-cloud-messaging

我在我的应用程序中需要FCM服务,我不能使用FirebaseMessagingService类,它说:

Error:(24, 8) error: zzaa(Intent) in FirebaseMessagingService cannot override zzaa(Intent) in zzb return type int is not compatible with Intent
Run Code Online (Sandbox Code Playgroud)

这是我的代码

public class MyFirebaseMessagingService extends FirebaseMessagingService {
  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    sendNotification(remoteMessage.getData().get("message"));
  }

  private void sendNotification(String messageBody) {
    //
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用这个版本的库 compile 'com.google.firebase:firebase-messaging:9.2.0'

在此输入图像描述

0xA*_*iHn 7

我通过改变这个问题修复了同样的问题:

compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.google.firebase:firebase-core:9.2.1'
Run Code Online (Sandbox Code Playgroud)

至:

compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.firebase:firebase-core:9.2.0'
Run Code Online (Sandbox Code Playgroud)

只是让所有这个版本都一样.


Sha*_*rge 5

尝试使用相同版本运行所有服务.在这种情况下改变

compile 'com.google.firebase:firebase-messaging:9.0.2' 
Run Code Online (Sandbox Code Playgroud)

compile 'com.google.firebase:firebase-messaging:9.2.0 
Run Code Online (Sandbox Code Playgroud)

并查看是否发生了同样的问题.

  • 我正在使用最新版本:/ (2认同)

小智 4

我解决了我的问题,我正在使用最新版本的谷歌地图和身份验证服务

compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
Run Code Online (Sandbox Code Playgroud)

当我将版本降级到9.2.0时问题得到解决