Firebase远程配置获取失败,出现FirebaseRemoteConfigClientException异常。

4

我为我的旧应用程序实现了Firebase远程配置,该应用程序已经使用Firebase崩溃分析和Firebase分析。这些服务都能正常工作,但是在使用远程配置时,我遇到了此身份验证令牌错误。

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)

我会尽力为您进行翻译,以下是翻译的结果:

我按照一个谷歌文档上的实现指南进行操作。我不确定是否漏掉了一步或多步。这是我的代码。

应用程序类

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);
    }
}

我正在主屏幕片段中使用fetch请求。我在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();
                }
            }
        });
    } 

有人能指出我错过了什么吗?在Firebase方面是否还有其他配置我错过了?

2
检查最后一个 @franvis 的评论 -> https://github.com/firebase/firebase-android-sdk/issues/1776。 - Haris
你最近改过 google-services.json 文件吗? - Batuhan
1
请告诉我,你是否找到了解决问题的方法?在迁移到 Firebase BoM(版本为 27.0.0)后,我也遇到了完全相同的问题。 - VladimirVip
4个回答

1

正如您所看到的,在错误日志的第8行中提到:

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

所以你可以尝试以下两个步骤:

  1. 如果你还没有添加 SHA证书指纹,请添加后,然后使项目失效并重新构建。
  2. 或者你可以直接删除 build文件,然后重新构建你的项目。

1
如果您的API密钥受到限制(应该是这样),请确保将开发证书和捆绑标识添加到密钥中。访问您的仪表板,从顶部菜单选择项目 -> API密钥,然后您应该可以看到它们(由Firebase自动创建)。

0

请使用已登录 Google Play 商店帐户的设备进行尝试。


0

如果您正在使用模拟器,请确保您的模拟器具有正常的互联网连接


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接