【问题标题】:Firebase remote config fetch failed with FirebaseRemoteConfigClientExceptionFirebase 远程配置获取失败并出现 FirebaseRemoteConfigClientException
【发布时间】:2021-01-21 08:48:33
【问题描述】:

我为已经使用 firebase crashlytics 和 firebase analytics 的旧应用程序实现了 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);
    }
}

我正在主屏幕片段中使用获取请求。我在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 方面做任何其他配置吗?

【问题讨论】:

  • 查看最后的@franvis 评论 -> github.com/firebase/firebase-android-sdk/issues/1776.
  • 您最近更改了 google-services.json 吗?
  • 请告诉我 - 您找到解决问题的方法了吗?迁移到 Firebase BoM(版本为 27.0.0)后,我面临完全相同的问题

标签: android firebase-remote-config


【解决方案1】:

正如你在错误日志的第 8 行看到的那样

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

所以你可以尝试 2 件事:

  1. 尝试添加SHA certificate fingerprints,如果您还没有这样做,则无效并 重建您的项目。
  2. 或者您可以简单地删除build 文件,然后重新构建您的项目。

【讨论】:

    【解决方案2】:

    如果您的 API 密钥受到限制(您应该这样做),请确保将您的开发证书和捆绑 ID 添加到密钥中。

    访问your dashboard,从顶部栏中选择项目 -> API 密钥,您应该会看到它们(由 Firebase 自动创建)。

    【讨论】:

      猜你喜欢
      • 2019-07-03
      • 2022-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 2021-09-19
      相关资源
      最近更新 更多