[🐛] 🔥 App crashes upon opening first time
Issue
As soon as I install this library in my React Native 0.66.4 project, my production releases for Android become very unstable.
I cannot reproduce this error on an empty project, however, in my project, I can literally reproduce this error using the following step:
yarn add @react-native-firebase/app // error occurs
yarn remove @react-native-firebase/app // error doesn't occur
When I open the mobile app for the first time it will always crash. If I open it a second time, it will open, but will crash after about a minute.
The issue occurs on different machines and App Center.
error log removed because it was not relevant
Project Files
Javascript
Click To Expand
package.json:
...
"@react-native-community/push-notification-ios": "^1.6.1",
"@react-native-firebase/app": "^14.2.1",
"@react-native-picker/picker": "^2.1.0",
...
firebase.json for react-native-firebase v6:
# Doesn't exist
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
buildscript {
ext {
...
// This was already present, but both with and without it we had this issue
// firebaseVersion = "17.3.4"
}
...
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.google.gms:google-services:4.3.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
android/app/build.gradle:
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
...
dependencies {
...
// This was already present, but both with and without we had this issue
implementation 'com.google.firebase:firebase-analytics:18.0.2'
}
android/settings.gradle:
// This file has no firebase-related code
MainApplication.java:
// This file has no firebase-related code
AndroidManifest.xml:
// This file has no firebase-related code
Environment
Click To Expand
react-native info output:
...
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-macos: Not Found
- Platform that you're experiencing the issue on:
- [X] Android
react-native-firebaseversion you're using that has this issue:- Not sure
Firebasemodule(s) you're using that has the issue:- Only
app
- Only
- Are you using
TypeScript?- Yes, 4.2.3
Interesting. None of those stack traces seem related to anything other than possible local project build issues of some sort. (libjsc, libhermes etc). I'm not sure any of those is actually the crash trace.
It appears we really will need a reproduction of this one
resources for the same, in case they help: https://stackoverflow.com/help/how-to-ask https://stackoverflow.com/help/minimal-reproducible-example https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh
@mikehardy thank you for having a look at this. I understand, I agree with you.
I was wondering though, but from what I understand the following sections can definitely be removed?
android/build.gradle:
buildscript {
ext {
...
// This was already present, but both with and without it we had this issue
// firebaseVersion = "17.3.4"
}
}
android/app/build.gradle:
dependencies {
...
// This was already present, but both with and without we had this issue
implementation 'com.google.firebase:firebase-analytics:18.0.2'
}
As these were already present before the integration, I suspect that the issue may be caused by a previous firebase integration was implemented.
I would definitely check out the make-demo script as it takes you through how to integrate, with comments. I would not specify the firebaseVersion or a specific firebase-analytics dependency unless I wanted either a) really fine-grained control over the version or b) I knew there was some specific incompatibility or bugfix in a non-default-from-react-native-firebase version that I was temporarily working around with a specific version
The only case where a) should apply in my opinion is if you are me and you are constantly test-integrating new versions before making PRs into react-native-firebase, or you have some strict dependency version control requirements. If you are in case B you will know it :-)
Otherwise, the module provides a very very up to date dependency on the underlying versions / libraries for firebase-android-sdk without you having to do anything to keep them up to date
I'm not sure why, but in the end, adding the following to android/app/build.gradle helped:
dependencies {
...
implementation 'com.google.firebase:firebase-iid:21.0.0'
...
}
I'm glad that worked for you but please note that the iid dependency is considered deprecated (and was always a bit "internal") and should not need to be used at any time. installations module is the current way to get "installation ids". So this solution may result in a working project now but I would consider it a huge flashing warning sign that some dependency is depending on some thing that it shouldn't, and I'd queue it for more inspection + cleanup, as I can almost guarantee it will break in the future