gpt4 book ai didi

Android Firebase 版本升级

转载 作者:行者123 更新时间:2023-12-03 15:48:37 32 4
gpt4 key购买 nike

我有一个使用 Firebase 和 GMS 服务的应用程序,版本为 11.8.0 2 年,现在,我想升级到最新版本是 17.0.0。 gradle 中的以下依赖项:

升级前:

implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.android.gms:play-services-base:11.8.0'
implementation 'com.google.firebase:firebase-invites:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-config:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'

升级后:
implementation 'com.google.firebase:firebase-analytics:17.2.3'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.1.0'
implementation 'com.google.firebase:firebase-invites:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.1.1'
implementation 'com.google.firebase:firebase-config:19.1.2'
implementation 'com.google.android.gms:play-services-maps:17.0.0'

并修改代码:
    public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

@Override
public void onTokenRefresh() {
//Getting registration token
String token = FirebaseInstanceId.getInstance().getToken();
// Save token
}
}


public class MyFirebaseInstanceIDService extends FirebaseMessagingService {

@Override
public void onNewToken(@NonNull String s) {
super.onNewToken(s);
// Save token
}
}

在 list 中,我保持注册服务如下:
<service android:name=".notification.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

我之前设置的所有其他内容都没有改变。
但是在构建和运行时,我在下面的堆栈跟踪中出现错误:
2020-03-12 11:38:29.225 26475-26543/com.example E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.
2020-03-12 11:38:29.460 26475-26550/com.example E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid@@20.1.0:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid@@20.1.0:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
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
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations@@16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations@@16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source: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) 

在谷歌上寻找解决方案后,我发现了这样的事情:
https://firebase.google.com/support/release-notes/android#2020-03-03

然后我转到我的 firebase 控制台并启用 Firebase 安装,但没有任何改变。那么有人可以帮我找出解决这个问题的方法吗?非常感谢大家!

最佳答案

更改 firebase-messaging版本为 20.1.0

implementation 'com.google.firebase:firebase-messaging:20.1.0'

关于Android Firebase 版本升级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60648040/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com