Android は Firebase Messaging Service を拡張できません 質問する

Android は Firebase Messaging Service を拡張できません 質問する

アプリケーションに Firebase Cloud Messaging を実装しようとしています。このサービスを使用するためのすべての設定を実装しましたが、FirebaseMessagingServiceクラスで拡張しようとするとエラーが発生し、まったく見つからないため、import com.google.firebase.messaging.FirebaseMessagingService図に示すようにできません。

ここに画像の説明を入力してください

必要なコードをすべて追加しました。これをアプリの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'

これはマニフェストコードです:

<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ファイルをアプリに追加しました。誰か助けてくれる人がいたらお願いします

ベストアンサー1

メッセージングを使用する場合は、メッセージング モジュールを追加する必要があります。現在はコア モジュールのみが追加されています。

ぜひ、

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

利用可能なすべてのモジュールは、セットアップ

おすすめ記事