gpt4 book ai didi

Android:哪个版本的 com.google.android.gms:play-services 与 com.google.firebase:firebase-messaging 兼容?

转载 作者:行者123 更新时间:2023-11-30 00:27:52 24 4
gpt4 key购买 nike

正在关注 this tutorial我尝试将 Firebase SDK 集成到一个 Android 应用程序中(实际上它是一个 ReactNative-Application 但在这个级别上它并不重要) 但是在使用时遇到了几个编译器错误来自 firebase-messaging 的类。

编译器声明只有 9.0.0 版本相互兼容。但是这些版本不能与教程中列出的客户端代码一起使用。

有些人(AB)写道,firebase-messaging 必须在 V 9.2.1 或 10.0.1 中编译,但 Android Studio 提示说这些版本与 google-play- 不兼容服务 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。无法访问 AbstractSafeParcelable

error: cannot access 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);
}
}

2。未找到 AbstractSafeParcelable

class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found

等等……

Gradle :

./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
}

我正在我当前的应用程序中使用它,所以它可以正常工作。祝你好运

关于Android:哪个版本的 com.google.android.gms:play-services 与 com.google.firebase:firebase-messaging 兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45033243/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com