简体   繁体   中英

Error “return type int is not compatible with Intent” when using FirebaseMessagingService class

I need FCM service in my application, I can't use FirebaseMessagingService class, it says :

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

here is my code

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

  private void sendNotification(String messageBody) {
    //
  }
}

I'm using this version of library compile 'com.google.firebase:firebase-messaging:9.2.0'

在此输入图像描述

I fixed this same problem in my case by changing this:

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'

To:

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'

Just make all this version are same.

Try running all services with the same version. In this case change

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

to

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

and see if the same issue happens.

I solved my problem, I was using the latest version of google map and auth services

compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'

when I downgrade version to 9.2.0 problem were solved

Why would you downgrade? It's better to bump the 'com.google.firebase:firebase-messaging' version to match the play-services version (9.4.0 in your case) and you are ready to go.

So compile 'com.google.firebase:firebase-messaging:9.4.0' will do the trick.

https://firebase.google.com/docs/android/setup

Please use the latest google-services plugin and firebase version.

If getting a "Could not find" error, please make sure you have the latest Google Repository in the Android SDK manager.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM