React-native-onesignal: (3.2.3) Android app crashes with Java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.{appname}. Make sure to call FirebaseApp.initializeApp(Context) first when calling `init()`

Created on 19 May 2018  ·  14Comments  ·  Source: OneSignal/react-native-onesignal

Description:

When calling OneSignal.init() in Android the app crashes with the error Java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.reactnativeprototype. Make sure to call FirebaseApp.initializeApp(Context) first

When not calling init and initializing the old way in the build.gradle the ids event never fires.

Environment
SDK: v3.2.3

Steps to Reproduce Issue:

  1. Use OneSignal.init() in Android. App will crash immediately

Most helpful comment

For now, it's working for me:

I updated my build.gradle for use a newer version (3.0.1) like in: .../examples/RNOneSignal/android/build.gradle

And also updated my gradle-wrapper.properties for gradle-4.1 like in: .../examples/RNOneSignal/android/gradle/wrapper/gradle-wrapper.properties

After that I start got some errors, then I changed my app/build.gradle:

...
dependencies {
    ...
    compile (project(':react-native-onesignal')){
        exclude group: "com.google.android.gms"
    }
    compile ("com.google.android.gms:play-services-base:12.0.1") {
        force = true;
    }
}
...

All 14 comments

Hoping for a solution too.. 😔

Same issue

@bighitbiker3 If you initialize the old way - using build.gradle, you can call OneSignal.configure() in JS to get the ids event to fire.

As far as this particular FCM issue, we'll investigate, thanks for reporting

Even calling configure with the old initialization doesn’t fire the id event for me

Sent from my iPhone

On May 19, 2018, at 11:28, Brad Hesse notifications@github.com wrote:

@bighitbiker3 If you initialize the old way - using build.gradle, you can call OneSignal.configure() in JS to get the ids event to fire.

As far as this particular FCM issue, we'll investigate, thanks for reporting


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@bighitbiker3 the same for me. I tried many things and I had to downgrade to the 3.1.4 version to make it work again along with React Navigation (RN 0.55.4).

@Nightsd01 The error I get when trying to run OneSignal.configure() to get the ids is You must initialize OneSignal before getting tags! Moving this tag operation to a pending queue.. This comes from the Android SDK here.

I've tried putting it in a timeout to make sure the Android init code is run before I call anything but still get the above error.

I'm having a hard time debugging from there because I'm a pretty big newb when it comes to importing external libraries in Android and RN 😅.

@bighitbiker3 Please try updating to 3.2.4 of the SDK and let me know if that fixes your issue.

I'm on version 3.2.4 and i'm getting the exact same error message when i call OneSignal.init()

I'm using 3.2.4 and having the same error with Onesignal.init()

For now, it's working for me:

I updated my build.gradle for use a newer version (3.0.1) like in: .../examples/RNOneSignal/android/build.gradle

And also updated my gradle-wrapper.properties for gradle-4.1 like in: .../examples/RNOneSignal/android/gradle/wrapper/gradle-wrapper.properties

After that I start got some errors, then I changed my app/build.gradle:

...
dependencies {
    ...
    compile (project(':react-native-onesignal')){
        exclude group: "com.google.android.gms"
    }
    compile ("com.google.android.gms:play-services-base:12.0.1") {
        force = true;
    }
}
...

@ramonsenadev that worked, thanks!

To anyone still having trouble with this, note that the React Native setup instructions have recently been updated. This new section in particular is what got everything working for me on 3.2.4. I still had the compileSdkVersion and buildToolsVersion set to the React Native defaults.

@ramonsenadev Thanks a lot. Your solution worked.
Few more steps i did after moving to onesignal v3.2.4 were:
compileSdkVersion 26
buildToolsVersion "26.0.1"
targetSdkVersion 26

Also make sure you update the android support library version
compile "com.android.support:appcompat-v7:26.0.1"

I also had to add following at the bottom of app/build.gradle

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.1'
            }
        }
    }
}

Thanks OneSignal team! Appears to be fixed in 3.2.4. Everyone please check out the link in @jsouza181's comment. Worked great for me

Was this page helpful?
0 / 5 - 0 ratings