Firebase Admin SDK Android

此生再无相见时 提交于 2020-04-14 07:19:01

问题


Code for Initialising Firebase-Admin SDK in Android

@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 while building the app for run:

error: cannot find symbol
                .setCredentials(GoogleCredentials.fromStream(serviceAccount)

error: incompatible types: FirebaseOptions cannot be converted to Context FirebaseApp.initializeApp(options);


回答1:


Admin SDK cannot and should not be used on Android. It is for server-side and other back-end environments only.



来源:https://stackoverflow.com/questions/51130436/firebase-admin-sdk-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!