Firebase 管理 SDK Android

Firebase Admin SDK Android

在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(选项);

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