【发布时间】:2018-07-02 06:45:55
【问题描述】:
在 Android 中初始化 Firebase-Admin SDK 的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_excel);
FileInputStream serviceAccount = null;
try {
serviceAccount = new FileInputStream("android.resource://com.app.hello/raw/hello.json");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
FirebaseOptions options = null;
try {
options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://hello.firebaseio.com/")
.build();
} catch (IOException e) {
e.printStackTrace();
}
FirebaseApp.initializeApp(options);
}
构建应用程序以供运行时出错:
error: cannot find symbol
.setCredentials(GoogleCredentials.fromStream(serviceAccount)
错误:不兼容的类型:FirebaseOptions 无法转换为 Context FirebaseApp.initializeApp(options);
【问题讨论】:
-
你能分享一下吗,如何在android中使用?