简体   繁体   中英

trying to connect react native app to firebase using expo

I am using expo "Bare workflow" in order to connect my react app to firebase.

This is what I have done so far following this tutorial :

  1. I had an existing firebase project which I am trying to connect to.

  2. I clicked on the android icon and registered the app also download the configuration part, I have even added Firebase SDK and applied the plugins, When I use

var admin = require("firebase-admin");

then I get this error:

在此处输入图像描述

in my app/build.gradle I do get the following error at:

import com.android.build.OutputFile

the error is: cannot resolve symbol "build"

how can I solve this?

I also clicked on the file and pressed on invalidate/ cache restart, and I did that too when I click on run on my android studios on the edit configuration window that pops open it tells me Error: AndroidManifest.xml doesn't exist or has incorrect root tag

when I click File->Project structure, there I see under project SDK that no SKD has been selected.

so I am not sure what is causing this problem.

Create your Firebase instance, then go to the left side where it says "Real Time Database" and set that up. Make sure you have react-native-firebase installed ( expo install react-native-firebase ). Create a config.js file that looks like this:

import Firebase from 'firebase';
let config = {
  apiKey: '',
  authDomain: '',
  databaseURL: '',
  projectId: '',
  storageBucket: '',
  messagingSenderId: ''
};
let app = Firebase.initializeApp(config);
export const db = app.database();

Fill this in with your information, which can be found in the firebase console after creating a web app for your firebase project. ( </> button).

Now that you have your firebase linked to your expo project, import your database using import { db } from '{path to your config file}';

Let me know if you need help pushing and pulling data from your RTDB instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM