アプリケーションに 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'
利用可能なすべてのモジュールは、セットアップ