AndroidStudio-ツールのFCM設定 - クラウドメッセージングのFirebaseアシスタントが正常にセットアップされました。したがって、セットアップは訂正されますが、Tokenは生成されません。MainActivityのトークン表示を介してlogcatおよびConfigクラスには生成されず、その表示はnullです。実行の問題の後、アンインストールされたアプリが続行されます。私も別のエミュレータを試してみましたが、解決策はありません。Firebase Cloud Messagingトークンが生成されません。
MyFirebaseInstanceIDService.java
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
@Override
public void onTokenRefresh() {
String newToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + newToken);
Config.TOKEN = newToken;
}
}
のAndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
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=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
build.gradle(プロジェクトレベル)
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
build.gradle(アプリケーションレベル)
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-messaging:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.squareup.okhttp:okhttp:2.0.0'
}
apply plugin: 'com.google.gms.google-services'
をマニフェストにこれを追加...あなたはあなたのアプリケーションのディレクトリの下にファイルを – Shanmugam
をgoogleservies.jsonしているのですか? – Raghunandan
はい、アプリケーションディレクトリ – Pinkesh