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:
I had an existing firebase project which I am trying to connect to.
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.
Related
Hey this is Shubham and i am 12 years old and i am an ardent learner of mobile app development with the cross platform language react native and i want to learn how
to build a full stack social media application with the use of firebase as backend but i am facing errors frequently in firebase when i try to
import * as firebase from 'firebase' it keeps throwing errors that says firebase module not found but i have already installed firebase in my expo
project. so How can i use multiple services of firebase in my project.
(my code is correct but still i am facing error)
you should cheack your firebase version in package.json depencence
in version 8 it should be some thing like this
"firebase": "^8.2.3",
this is how you can import them
import * as firebase from "firebase";
import "#firebase/auth";
import "firebase/storage";
import "firebase/firestore";
const firebaseConfig = {
apiKey: "....",
authDomain: "..",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "..",
};
firebase.initializeApp(firebaseConfig);
export default firebase;
if its version 9 you have to import them differently
however, you can change the version in package.json to "^8.2.3"
than do
" npm install " in the terminal
I'm trying to connect firebase first time with my react-native application but facing an issue which is that:
Error: Missing or invalid FirebaseOptions property 'apiKey'. I try to search to solve that problem but it doesn't solve.
import Firebase from '#react-native-firebase/app'
useEffect(()=>{
Firebase.initializeApp()
},[])
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath 'com.google.gms:google-services:4.3.0'
}
Now according to my searches i do the following things to solve it
clean my android gradlew
Reinstall the node modules
Change the google-services:4.3.10 ->4.3.0
Redownload the google-serives.json file
but it doesn't work for me
I'm not sure if this helps, but I noticed you don't seem to be configuring Firebase.
This is older code from a prior project where I used Firebase (keys changed for anonymity).
Please note:
//Configure Firebase
var app = firebase.initializeApp({
apiKey: "AIzaSyBA-nJOSHcALkHfR7D7GsBqzU5qmCHY_WA",
authDomain: "project-e6136.firebaseapp.com",
databaseURL: "https://project-e6136.firebaseio.com",
projectId: "project-e6136",
storageBucket: "",
messagingSenderId: "948984656115"
});
I think you need to pass an object into the initializeApp(), with your keys.
In my case, I setup these keys at https://firebase.google.com/, when I registered an account.
Hopefully this helps, or please comment, if I misunderstood your question.
When I transitioned to Expo's Managed Workflow (SDK 37 and now 38 as well), in-app update checking broke.
My code:
import * as Updates from 'expo-updates';
async checkForUpdate() {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
this.updateApp();
}
}
async updateApp() {
await Updates.fetchUpdateAsync();
Updates.reloadAsync();
}
Logcat shows me that the checkForUpdateAsync() promise is being rejected with this message:
Error: The method or property Updates.checkForUpdateAsync is not available on android, are you sure you’ve linked all the native dependencies properly?
For the record I did install it via expo install expo-updates
Thanks.
I solved this by creating a new Expo project and looking for differences from my many-times-upgraded one. I found two:
I was using off-the-shelf React Native instead of the Expo build, so I changed the dependency in package.json to "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.1.tar.gz"
I also updated my expo version to ^38.0.8, as used by the new project.
Finally, I also deleted some build relics that I had generated during the way, but I think the fix came from one of the steps above.
I created ionic 3 app with firebase
the application start correctly, and connected to firebase DB.and can perform CRUD operations.
when I deploy app using command
$ ionic cordova build --release android
I got error message:
No matching client found for package name 'io.ionic.starter'
note: the file 'google-services.json' is missing
and my app is not shown inside Firebase console pic
I initialize firebase inside app module:
// Initialize Firebase
var config = {
apiKey: "AIzaSyDGJaayYxyasdufYG7GKo36nUMdsfU",
authDomain: "firedo-3997a.firebaseapp.com",
databaseURL: "https://firedo-3997a.firebaseio.com",
projectId: "firedo-3997a",
storageBucket: "firedo-3997a.appspot.com",
messagingSenderId: "578088897558"
};
firebase.initializeApp(config);
please help me deploying this app
You need to add a google-services.json file to the root file of your ionic project from firebase.
And you must make the in the config.xml file like the name of your project in firebase.
I have an android project which I want to expand with Firebase.
Currently I've got an error logging when I want to test a crash with a log message.
Server did not receive report: Origin Error message: API key not valid. Please pass a valid API key.
What can I do to fix this?
I've copied the google-services.json file to my project from the console.
Got the same error in my Angular project. I know the question is for android but this is the question that pops up when I searched the error for angular so hopefully, it would help another person in the near future.
Make sure you're importing the right variable. In the app.module.ts file:
import { FIREBASE } from 'src/environments/firebase';
imports: [
AngularFireModule.initializeApp(FIREBASE.firebase)
],
firebase.ts (environment file) fill with your config info from firebase.
export const FIREBASE = {
production: false,
firebase: {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
}
};
So make sure you're importing the right variable. Took me some time to figure out. Happy coding!
Make sure you've got the API keys set correctly in your Google Developer Console for your Firebase project.
There are two different configurations for release mode and test mode. make sure that you use the API key which is related to each. In the angular there are two environment files. environment.prod.ts which is for production and environment.ts which is for testing. make sure that the api key in these files are correct.
good night, I solved this problem with
npm i firebase --save