无法解析FirebaseOptions.Builder().setCredentials() [英] Can not Resolved FirebaseOptions.Builder().setCredentials()

查看:91
本文介绍了无法解析FirebaseOptions.Builder().setCredentials()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Trying to achieve Firebase authentication using customToken.

在执行以下操作时出错:

Getting error while doing below:

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

        FirebaseApp.initializeApp(options); 

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

It says can not resolve setCredentials() and after this when I'm trying to creat token is gives same error:

FirebaseAuth.getInstance().createCustomToken(uid);

在网上搜索找不到解决方案,请帮助

Searched all over the net cant find solution please help

使用的依赖项如下:

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'

推荐答案

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

The perfect answer to question is to add below dependency to your app level graddle file.

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

所有问题都将得到解决.

all the issues will be solved.

这篇关于无法解析FirebaseOptions.Builder().setCredentials()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆