使用FirebaseOptions.Builder()编译setServiceAccount()的时间错误 [英] Compile time error for setServiceAccount() with FirebaseOptions.Builder()

查看:264
本文介绍了使用FirebaseOptions.Builder()编译setServiceAccount()的时间错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用我的Android应用使用Firebase云消息发送推送通知。我参照 https://firebase.google.com/docs/指南设置我的服务器server / setup#prerequisites

我的项目级别build.gradle是这样的:

 依赖关系{
classpath'com.android.tools.build:gradle:2.1.0'
classpath'com.google.gms:google-services:3.0.0'

应用程序级别build.grade:

 依赖项{
compile'c​​om.firebase:firebase-client-android:2.5.2'
compile'c​​om.firebase:geofire:1.1。 0'
compile'c​​om.google.android.gms:play-services-gcm:9.0.0'
compile'c​​om.google.android.gms:play-services:9.0.0'
compile'c​​om.google.firebase:firebase-messaging:9.0.0'
compile'c​​om.google.firebase:firebase-server-sdk:[3.0.0,''
compile'c​​om .google.firebase:firebase-core:9.0.0'

}



我在控制台上创建了服务帐户凭据,但在初始化SDK时,请参阅 https://firebase.google.com/docs/server/setup#add_the_sdk

  FirebaseOptions选项= new FirebaseOptions.Builder()
.setServiceAccount
(new FileInputStream(path / to / serviceAccountCredentials.json))
.setDatabaseUrl(https://databaseName.firebaseio.com/ )
.build();

错误:(116,21)错误:找不到符号方法setServiceAccount(FileInputStream)

我检查了很多地方,但我无法找到我做错的地方。任何帮助将不胜感激。

解决方案

在您的服务器项目中,您只需使用依赖项:

com.google.firebase:firebase-server-sdk:[3.0.0,)并删除:

  compile'c​​om.firebase:firebase-client-android:2.5.2'
compile'c​​om.google.android.gms:play-services-gcm:9.0.0'
编译'com.google.android.gms:play-services:9.0.0'
编译'com.google.firebase:firebase-messaging:9.0.0'
编译'com.google .firebase:firebase-core:9.0.0'

第一个是服务器sdk,而其他的是客户端sdk,如果您尝试将它们一起使用,它们将会发生冲突。


I was working my Android app for sending push notifications using Firebase cloud messaging. I was setting up my server referring the guide https://firebase.google.com/docs/server/setup#prerequisites.

My project level build.gradle is like :

dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}

App level build.grade :

dependencies {   
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:geofire:1.1.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'
compile 'com.google.firebase:firebase-core:9.0.0'

}

I have created the service account credentials on the console as well but while I am initializing the SDK referring https://firebase.google.com/docs/server/setup#add_the_sdk

FirebaseOptions options = new FirebaseOptions.Builder()
.setServiceAccount
(new  FileInputStream("path/to/serviceAccountCredentials.json"))
.setDatabaseUrl("https://databaseName.firebaseio.com/")
.build();

I am getting compile Error:(116, 21) error: cannot find symbol method setServiceAccount(FileInputStream)

I have checked many places but I am unable to find what I am doing wrong. Any help would be highly appreciated.

解决方案

In your server project you need to use only the dependency:
com.google.firebase:firebase-server-sdk:[3.0.0,) and remove:

compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'

The first is a server sdk while the others are client sdk and they will have conflicts if you try to use them together.

这篇关于使用FirebaseOptions.Builder()编译setServiceAccount()的时间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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