S. N
S. N

Reputation: 3959

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:

enter image description here

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.

Upvotes: 0

Views: 736

Answers (1)

Nate.Olson
Nate.Olson

Reputation: 153

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.

Upvotes: 1

Related Questions