Firebase remote config fetch failed with FirebaseRemoteConfigClientException

I implemented the firebase remote config for my old application which already using firebase crashlytics and firebase analytics. Those services are working fine. Buth with the remote config I'm getting this auth token error.

com.google.firebase.remoteconfig.FirebaseRemoteConfigClientException: Firebase Installations failed to get installation auth token for fetch.
at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetchIfCacheExpiredAndNotThrottled$1(ConfigFetchHandler.java:209)
at com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$2.then(Unknown Source:8)
at com.google.android.gms.tasks.zzg.run(com.google.android.gms:play-services-tasks@@17.0.2:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:147)
at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:490)
at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:361)
at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$2(FirebaseInstallations.java:351)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$4.run(Unknown Source:4)

I followed the implementation guide on a google document. I'm not sure whether I missed any step. here's my code.

ApllicationClass

public class Global extends Application {

    public static FirebaseRemoteConfig REMOTE_CONFIG = null;

    @Override
    public void onCreate() {
        super.onCreate();

        REMOTE_CONFIG = FirebaseRemoteConfig.getInstance();
        FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
                .setMinimumFetchIntervalInSeconds(3600)
                .build();
        REMOTE_CONFIG.setConfigSettingsAsync(configSettings);
        REMOTE_CONFIG.setDefaultsAsync(R.xml.remote_config_defaults);
    }
}

And I'm using the fetch request in the home screen fragment. I'm calling the below method in onViewCreated

private void getRemoteConfig(){

        Global.REMOTE_CONFIG.fetchAndActivate().addOnCompleteListener(requireActivity(), task -> {

            if (task.isSuccessful()) {
                String home_screen_status = Global.REMOTE_CONFIG.getString("home_screen_status");
            }else{
                try {
                    throw task.getException();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    } 

Can someone point me out what am I missing? Is there any other configuration I have to do on firebase side that I'm missing?

Upvotes: 4

Views: 11531

Answers (4)

Muhammad Raqib
Muhammad Raqib

Reputation: 344

If you are using an emulator make sure your emulator is having a working internet connection

Upvotes: 1

Rishabh Saxena
Rishabh Saxena

Reputation: 1795

Try the device with a google play store account logged in.

Upvotes: 0

Underscore
Underscore

Reputation: 1062

If you have your APIs keys restricted (which you should), make sure you add your dev certificate and bundle ID to the key/s.

Visit your dashboard, select the project from top bar -> API keys and there you should see them (auto created by Firebase).

Upvotes: 1

Keshav
Keshav

Reputation: 173

as you can see it's saying in the 8th line of error log

Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.

so you can try 2 things:

  1. Try adding SHA certificate fingerprints if you haven't done that, then Invalidate and rebuild your project.
  2. or you can simply delete build file, and rebuild your project.

Upvotes: 1

Related Questions