gpt4 book ai didi

java - 无法解决 FirebaseOptions.Builder().setCredentials()

转载 作者:行者123 更新时间:2023-12-02 02:03:38 31 4
gpt4 key购买 nike

尝试使用 customToken 实现 Firebase 身份验证。

执行以下操作时出现错误:

FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("path to file") //different in actual
.build();

FirebaseApp.initializeApp(options);

它说无法解析setCredentials(),此后当我尝试创建 token 时给出相同的错误:

FirebaseAuth.getInstance().createCustomToken(uid);

网上搜了很多遍都没有找到解决办法,请帮忙

使用的依赖关系如下:

implementation 'com.google.firebase:firebase-core:11.0.4'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.google.firebase:firebase-appindexing:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-perf:16.0.0'
implementation 'com.firebase:firebase-client-android:2.5.2+'
implementation 'com.firebase:firebase-client-android:2.5.2+'
implementation 'com.google.android.gms:play-services-analytics:11.0.4'
implementation 'com.google.android.gms:play-services-location:11.0.4'
implementation 'com.google.android.gms:play-services-auth:11.0.4'

最佳答案

问题的完美答案是将以下依赖项添加到您的应用程序级 graddle 文件中。

implementation 'com.google.firebase:firebase-admin:6.2.0'

所有的问题都会得到解决。

关于java - 无法解决 FirebaseOptions.Builder().setCredentials(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51185807/

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