As in the title. Fetching Firebase config crashes the app. In the same application Firebase database and crash reporting works perfectly.
Error messsage:
Caused by: java.lang.IllegalStateException: Activity has been destroyed
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1854)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:643)
at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:608)
at com.google.android.gms.internal.zzrn.zza(Unknown Source)
at com.google.android.gms.internal.zzra.zzc(Unknown Source)
at com.google.android.gms.internal.zzra.zzs(Unknown Source)
at com.google.android.gms.tasks.zzh$zza.zzv(Unknown Source)
at com.google.android.gms.tasks.zzh.addOnCompleteListener(Unknown Source)
at com.foo.foo.Common.DatabaseManager.getRemoteConfig(DatabaseManager.java:85)
at
I do not understand what is going. The related code:
private void getRemoteConfig() {
remoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
remoteConfig.setConfigSettings(configSettings);
remoteConfig.setDefaults(R.xml.remote_config_defaults);
long cacheExpiration = 3600;
//expire the cache immediately for development mode.
if (remoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
remoteConfig.fetch(cacheExpiration).addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
remoteConfig.activateFetched();
}
//LocalBroadcastManager.getInstance(null).sendBroadcast(new Intent(AppConstants.kNotificationonRemoteSettingsLoaded));*/
}
});
}
Graddle:
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.google.firebase:firebase-config:9.6.1'
compile 'com.google.firebase:firebase-crash:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.android.support:appcompat-v7:25+'
compile 'com.google.android.gms:play-services-maps:9.6.1'
apply plugin: 'com.google.gms.google-services'
I've had the same problem. The issue was that I've used firebase remote config fetch before
Super.oncreate()
. Check where you call thegetRemoteConfig()
procedure!