Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to initialize #9

Closed
lobo922 opened this issue Mar 18, 2017 · 20 comments
Closed

Unable to initialize #9

lobo922 opened this issue Mar 18, 2017 · 20 comments

Comments

@lobo922
Copy link

lobo922 commented Mar 18, 2017

I'm trying to initialize Firebase from JS as following:

  1. I configured this module on a clean project
  2. In index.android.js added the line import RNFirebase from 'react-native-firebase'
  3. In index.android.js i added the following before render():
    componentWillMount() {
    firebase.initizlizeApp({
    apiKey: 'apikey',
    authDomain: 'authdomain',
    databaseURL: 'dburl',
    storageBucket: 'bucket',
    messagingSenderId: 'senderid'
    });
    }
  4. i also tried to do it different as in the example:
    componentWillMount() {
    const firebase = new RNFirebase();
    const configurationOptions = {
    debug: true,
    googleAppID: 'appid',
    APIKey: 'appkey',
    databaseURL: 'dburl',
    storageBucket: 'bucket',
    androidClientID: 'clientid',
    GCMSenderID: 'senderid'
    };
    const firebase = new RNFirebase(configurationOptions);
    }

But in both attemps i get the following error on the emulator:
Default FirebaseApp is not initialized in this process com.xxx. Make sure to call FirebaseApp.initializeApp(Context) first. getInstance null:-1 getInstance null:-1 <init> RNFirebaseAuth.java:50 createNativeModules RNFirebasePackage.java:38 processPackage NativeModuleRegistryBuilder.java:88 processPackage ReactInstanceManager.java:950 createReactContext ReactInstanceManager.java:891 access$600 ReactInstanceManager.java:104 doInBackground ReactInstanceManager.java:218 doInBackground ReactInstanceManager.java:197 call AsyncTask.java:304 run FutureTask.java:237 runWorker ThreadPoolExecutor.java:1133 run ThreadPoolExecutor.java:607 run Thread.java:761

Am i doing anything wrong?

@Ehesp
Copy link
Member

Ehesp commented Mar 18, 2017

initizlizeApp in RNFirebase doesn't work like the web SDK. The docs need an update, as they don't accept the parameters as shown. You need to add an app on the firebase console, and add the google-services.json file or plist file (android/ios).

@lobo922
Copy link
Author

lobo922 commented Mar 19, 2017

Could you be more specific?
I added the file and I get the same result
Do I need to also manually add google services?
What else should I do?

@Salakar
Copy link
Member

Salakar commented Mar 20, 2017

@lobo922 you also need to add google services to your gradle files, otherwise it won't get loaded

@Salakar
Copy link
Member

Salakar commented Mar 23, 2017

Closing this and making a note to update the android setup docs. @lobo922 if you still have an issue please reply and i'll re-open.

@Salakar Salakar closed this as completed Mar 23, 2017
@ghost
Copy link

ghost commented Apr 3, 2017

I'm getting the run-time error:

"Default FirebaseApp is not initialized in this process com.react_native. Make sure to call FirebaseApp.initiailizeApp(Context) first"

@Ehesp
Copy link
Member

Ehesp commented Apr 3, 2017

@ghost
Copy link

ghost commented Apr 3, 2017

@Ehesp Thank you for your reply. I somehow managed to get it to work.

I think I wasn't pulling in google-services correctly.

Here are my notes:

###
#Firebase:
###See: console.firebase.google.com

#Download: google-services.json
#Copy and paste it in to /app

Project-level build.gradle (<project>/build.gradle):

buildscript {
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:3.0.0'
  }
}
App-level build.gradle (<project>/<app-module>/build.gradle):

...


// Add the following to react_native bundle.gradle:
dependencies {
   ...
   compile "com.android.support:appcompat-v7:23.0.1"
   ...
}

// Add the following to "app" bundle.gradle
dependencies{
   ...
   compile "com.android.support:appcompat-v7:23.0.1"
   ...
}

// Add to the bottom of the file (app bundle.gradle)
apply plugin: 'com.google.gms.google-services'

@Salakar
Copy link
Member

Salakar commented Apr 4, 2017

@hynese any chance you'd be able to review the installation docs on here and let me know if anything was missing based on your experience?

@bakr-baroudi
Copy link

I am having this issue too. Any updates?

@Salakar
Copy link
Member

Salakar commented Apr 6, 2017

@bakr-baroudi have you followed the setup instructions from the readme for the platform you're on?

Platform setup guides:
ios android

@bakr-baroudi
Copy link

Hi @Salakar,
Yeah I did follow the setup for iOS works find but Android got an issue.

what do you mean by this:
"There are several ways to setup Firebase on Android. The easiest way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform"

  • I have tried to pass the configuration when creating the firebase instance, but did not work for me.
    it says : "Default FirebaseApp is not initialized in this process com.react_native. Make sure to call FirebaseApp.initiailizeApp(Context) first".

  • I have tried to include google-services.json file under android/app and the other two steps. but did not work. it says: "Google Play Services is required to run this application but no valid installation was found".

@Ehesp
Copy link
Member

Ehesp commented Apr 6, 2017

@Ehesp
Copy link
Member

Ehesp commented Apr 6, 2017

Also @bakr-baroudi

what do you mean by this:
"There are several ways to setup Firebase on Android. The easiest way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform"

Where are you reading this from?

EDIT: Mybad. This was pulled from Firestack. Needs changing.

@Salakar
Copy link
Member

Salakar commented Apr 6, 2017

@bakr-baroudi I have updated the docs now, can you look over them again and see if anything has been missed your end: https://github.com/invertase/react-native-firebase/blob/master/docs/firebase-setup.md

@bakr-baroudi
Copy link

Thanks guys for replying. @Salakar @Ehesp
I am still getting this issue on Nexus 6A emulator (API 6.0).
Error Msg => "Google Play Services is required to run this application but no valid installation was found".
I change the debugging into my real device (API 7.0) then it works.

@Ehesp
Copy link
Member

Ehesp commented Apr 7, 2017 via email

@Ehesp
Copy link
Member

Ehesp commented Apr 7, 2017

@bakr-baroudi for clarity, your emulators need to include "Google APIs" once you'd installed via SDK manager:

image

@deavial
Copy link

deavial commented May 27, 2017

Wait a sec I am confused. My iOS app is working fine and I am passing the configuration information in js. The android app is not and is giving the not initialized error.

From what I am reading here, you are saying I can't configure this in js? I HAVE to configure this in JS as the connection information is coming down via json based on the tenant they have authenticated in to. So how do I configure this without hardcoding the app, which is not an option.

@chrisbianca
Copy link
Contributor

@victoriafrench That's an interesting use case that we hadn't envisaged! At the moment, as you've found, the initialisation relies on the GoogleServiceInfo.plist (iOS) and google-services.json (Android) files for configuration information.

We can certainly look at supporting custom configuration, we'd just been trying to keep it simple at first. Out of interest, are you needing to connect to multiple projects simultaneously? Or is there only one project active at any one time?

@caseyt
Copy link

caseyt commented Jun 8, 2018

Is there any resolution for this? My iOS app works fine with dynamic configuration through JS but the Android app does not. I need to connect to a different firebase app based on my app's environment configuration and cannot have a static google-services.json file. Why have the firebase.initializeApp() function if it does not work on Android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants