在本教程之后,我尝试将Firebase SDK集成到Android应用程序中(实际上它是一个ReactNative应用程序,但在这个级别上没关系(,但是在使用Firebase消息传递中的类时遇到了几个编译器错误。
编译器声明只有版本 9.0.0 彼此兼容。但这些版本不能与教程中列出的客户端代码一起使用。
有些人(A,B(写道,firebase消息传递必须在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.
这些是编译器错误:
1. 无法访问抽象安全包
错误:无法访问抽象安全包裹 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);
}
}
2. 摘要未找到安全包裹
的类文件 com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable 未找到
等等...
格拉德尔:
./android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.0'
./android/app/build.gradle:
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'
您必须在应用级别 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
}
我正在我当前的应用程序中使用它,所以它可以工作。