如何解决Firebase 远程配置获取失败,FirebaseRemoteConfigClientException
我为我的旧应用程序实现了 firebase 远程配置,该应用程序已经使用了 firebase crashlytics 和 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 方面做任何其他我缺少的配置吗?
解决方法
正如你在错误日志的第 8 行看到的那样
Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
所以你可以尝试两件事:
- 如果您还没有添加
SHA certificate fingerprints
,请尝试添加,然后 Invalidate 和 重建您的项目。 - 或者您可以简单地删除
build
文件,然后重新构建您的项目。
如果您的 API 密钥受到限制(您应该这样做),请确保将您的开发证书和捆绑 ID 添加到密钥中。
访问 your dashboard,从顶部栏中选择项目 -> API 密钥,您应该会看到它们(由 Firebase 自动创建)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。