2016-08-05 15 views
5

Tôi cần dịch vụ FCM trong ứng dụng của tôi, tôi không thể sử dụng lớp FirebaseMessagingService, nó nói:Lỗi "kiểu trả về int không tương thích với Ý định" khi sử dụng FirebaseMessagingService lớp

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

đây là mã của tôi

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

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

tôi đang sử dụng phiên bản này của thư viện compile 'com.google.firebase:firebase-messaging:9.2.0'

enter image description here

+0

Có cùng vấn đề –

Trả lời

4

tôi giải quyết vấn đề của tôi, tôi đã sử dụng phiên bản mới nhất của bản đồ google và dịch vụ auth

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

khi tôi hạ cấp phiên bản để 9.2.0 vấn đề đã được giải quyết

5

Thử chạy tất cả các dịch vụ có cùng phiên bản. Trong trường hợp này thay đổi

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

để

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

và xem nếu vấn đề tương tự xảy ra.

+2

Tôi đang sử dụng phiên bản mới nhất:/ –

+0

đã giải quyết được sự cố của tôi. ty –

7

Tôi cố định vấn đề này cùng trong trường hợp của tôi bằng cách thay đổi này:

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' 

Để:

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' 

Chỉ cần làm cho tất cả phiên bản này giống nhau.

2

Tại sao bạn hạ cấp? Tốt hơn là nên sử dụng phiên bản 'com.google.firebase: firebase-messaging' để khớp với phiên bản dịch vụ phát (9.4.0 trong trường hợp của bạn) và bạn đã sẵn sàng.

Vì vậy, compile 'com.google.firebase:firebase-messaging:9.4.0' sẽ thực hiện thủ thuật.

0

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

Vui lòng sử dụng plugin dịch vụ google và phiên bản firebase mới nhất.

Nếu gặp lỗi "Không thể tìm thấy", hãy đảm bảo bạn có Kho lưu trữ Google mới nhất trong trình quản lý SDK Android.

Các vấn đề liên quan