【问题标题】:Firebase Admin SDK AndroidFirebase 管理员 SDK Android
【发布时间】: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中使用?

标签: android firebase-admin


【解决方案1】:

Admin SDK 不能也不应该在 Android 上使用。它仅适用于服务器端和其他后端环境。

【讨论】:

  • 在android studio中做一个java项目解决了
  • @groupwork 能否分享一些链接或视频,以便我们根据您的评论进行参考。
猜你喜欢
  • 2017-09-23
  • 2019-03-14
  • 2019-12-28
  • 2019-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-21
  • 1970-01-01
相关资源
最近更新 更多