gpt4 book ai didi

java - Android 无法扩展 Firebase 消息服务

转载 作者:IT老高 更新时间:2023-10-28 23:19:41 27 4
gpt4 key购买 nike

我正在尝试在我的应用程序中实现 Firebase 云消息传递,我已经实现了使用此服务的所有设置,但是当我尝试在我的类中扩展 FirebaseMessagingService 时,它给了我错误并且它可以根本找不到,连import com.google.firebase.messaging.FirebaseMessagingService如图:

enter image description here

我已经添加了所有需要的代码:我将此添加到应用程序 gradle

compile 'com.google.firebase:firebase-core:9.4.0' 
apply plugin: 'com.google.gms.google-services'

这个到模块 gradle:

classpath 'com.google.gms:google-services:3.0.0'

这是 list 代码:

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>

然后我将 google json 文件添加到应用程序中。所以如果有人可以帮助我,请

最佳答案

如果你想使用消息传递,你必须添加消息传递模块。现在你只添加了核心模块。

所以继续,包括

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

所有可用的模块都可以在 https://firebase.google.com/docs/android/setup 的底部找到

关于java - Android 无法扩展 Firebase 消息服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39353857/

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