名称为 [DEFAULT] 的 FirebaseApp 不存在
迁移到 Firebase Cloud Messaging 后,打开我的应用时,它会崩溃并抛出一个错误,指出我已经放置了新的 google-services.json 并更新了我的 SDK。java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
这是我的主要活动
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());
}
}