I've read other posts on this issue, but none of them are helping me. My issue is that I NEVER get a token. I can reinstall the app, whatever, it never generates.
Is there something that I need to do to initialize Firebase?
Here is some background:
I have a google-services.json
file that I downloaded from the Firebase console stored under the src directory.
I have entered my debug.keystore
SHA 1 fingerprint on the Firebase console.
I have the following dependencies in my build.gradle
file:
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
I have followed the Firebase instructions to the letter:
MyFirebaseInstanceIdService.java
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
@Override
public void onTokenRefresh() {
Log.d(TAG, "on token refresh");
// Get updated InstanceID token.
String token = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + token);
sendRegistrationToServer(token);
}
private void sendRegistrationToServer(String token) {
}
}
And I have this within the <application>
tag in the manifest:
<service
android:name=".HelperClasses.PushNotifications.MyFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
In desperation, I added this line to the onCreate() method of my MainActivity.java file:
FirebaseInstanceId.getInstance().getToken();
This just crashes the app with this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mobilenicity.werun/com.mydomain.myapp.Activities.ViewControllers.MainActivity}: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
Of course, I've researched that error, but none of the solutions have helped me.
No idea where to turn next, but I'm clearly missing something. Can anyone shed some light on this? Thank you.
EDIT
Here is the module build.gradle
file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {url 'https://oss.sonatype.org/content/repositories/snapshots/'}
}
}