关注this tutorial我尝试将Firebase SDK集成到Android应用程序中(实际上它是一个ReactNative-Application但在此级别上并不重要)但是遇到了几个编译器 - 在使用firebase-messaging中的类时出错。
编译器声明只有版本9.0.0相互兼容。但是这些版本不能与教程中列出的客户端代码一起使用。
有些人(A,B)写道,firebase-messaging必须在V 9.2.1或10.0.1中编译,但Android Studio投诉,那些版本与这些版本不兼容google-play-services 10.0.1。 当我将google-play-services增加到11.0.1(没有10.0或9.2可用)时,情况也是如此:
Found com.google.firebase:firebase-core:9.2.1, but version 9.0.0 is needed for the google-services plugin.
Found com.google.firebase:firebase-messaging:9.2.1, but version 9.0.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of
the google-services plugin (information about the latest version is available at
https://bintray.com/android/android-tools/com.google.gms.google-services/)
or updating the version of com.google.android.gms to 9.0.0.
这些是编译器错误:
错误:无法访问AbstractSafeParcelable i.putExtra(“data”,remoteMessage);
package com.cooblr.notification;
import android.content.Intent;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class MessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent i = new Intent("Message");
i.putExtra("data", remoteMessage);
sendOrderedBroadcast(i, null);
}
}
类文件 com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable 找不到
依旧......
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
答案 0 :(得分:1)
您必须在应用级别gradle中添加以下内容
dependencies {
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
并在项目级别gradle中
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
我在我当前的应用程序中使用它,所以它的working.goodluck