mori mori - 6 months ago 1439
Android Question

FirebaseApp with name [DEFAULT] doesn't exist

After migrating to Firebase Cloud Messaging.When opening my app it crashes and throws an error saying

java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
I already put my new google-services.json and update my SDK.

Here's my MainActivity

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//Check Google play service
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int resultCode = googleAPI.isGooglePlayServicesAvailable(this);

if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.e(LOG_TAG, "This device is not supported.");
finish();
}
}

Log.i(TAG, "InstanceID token: " + FirebaseInstanceId.getInstance().getToken());

}
}

Answer

Please do double check, you added

apply plugin: 'com.google.gms.google-services' 

at the bottom of app's gradle file and then clean and rebuild the project