Android无法扩展Firebase Messaging Service [英] Android can't extend Firebase Messaging Service

查看:399
本文介绍了Android无法扩展Firebase Messaging Service的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to implement Firebase Cloud Messaging in my application, I had implemented all settings to use this service, but when I try to extend FirebaseMessagingService in my class it gives me error and it can't find it at all, I can't even import com.google.firebase.messaging.FirebaseMessagingService as shown in the picture:

我添加了所有必需的代码:
我将此添加到app gradle

I had added all the code required: I added this to app gradle

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

这是module gradle:

and this to the module gradle:

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

这是清单代码:

<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>

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

and I added the google json file to the app. So if anybody can help me please

推荐答案

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

If you want to use messaging, you have to add the messaging module. Right now you only added the core module.

所以继续并包括

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

全部可在 https://firebase.google.com/docs/android/底部找到可用模块设置

这篇关于Android无法扩展Firebase Messaging Service的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆