React Native application using Firebase

Asked

Viewed 629 times

1

Hello, I am creating an application using React Native, and trying to integrate with Firebase, I found an application of Starter project, which already has the integration ready, just need to add the google-services.json to the root directory of the android application, android/app, I followed all the steps that are described in the Readme of the repository that is in the following URL:

https://github.com/invertase/react-native-firebase-starter

That said, and done all the steps described to start the project, I performed the entry of the following command on the console, so that the project started: npm run android, from which returns me the following error:

   > Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :app:processDebugGoogleServices FAILED
Parsing json file: C:\Development\react-native-firebase-starter\android\app\google-services.json


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.unisul.testcar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
16 actionable tasks: 1 executed, 15 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

1 answer

3


Try using Firebase this way:

  1. Go to http://firebase.google.com/
  2. Go to the Console and create a new project
  3. After creating the project, choose to add "Authentication" for example. Under "Login Method", choose "Email/Password" or any other of your choice
  4. Once that’s done, in the upper right-hand corner, go to "Web Setup" to grab your credentials and paste this into your App.js, for example:

    class App extends Component {
        componentWillMount() {
        const firebase = require('firebase');
    
        const config = {
          apiKey: 'xxxx',
          authDomain: 'xxxx',
          databaseURL: 'xxxx',
          projectId: 'xxxx',
          storageBucket: 'xxxx',
          messagingSenderId: 'xxxx'
        };
        firebase.initializeApp(config);
    }
    

Install Firebase in your project using npm:

    npm install --save firebase

Test and see if it works.

  • 1

    It worked as expected!! Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.