I am trying to implement Crashlytics to my React Native project, but for some reason my crashes are not reported in Firebase.
One thing to mention also is that Im using Analytics package without any issues - they all get reported - and I have DEBUGVIEW enabled which gives me instant logging of events.
Im importing and executing force crash code in one of my main components on component will mount.
import crashlytics from '@react-native-firebase/crashlytics';
UNSAFE_componentWillMount() {
crashlytics().log('Testing crash');
crashlytics().crash();
analytics().setCurrentScreen("Home", "Home");
Click To Expand
#### `android/build.gradle`:
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
classpath 'com.google.gms:google-services:4.3.2'
classpath 'io.fabric.tools:gradle:1.31.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
}
}
#### `android/app/build.gradle`:
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def useIntlJsc = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.patrianap"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 7
versionName "1.3"
manifestPlaceholders = [
appAuthRedirectScheme: 'patrianap.com'
]
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
api 'androidx.appcompat:appcompat:1.0.0'
implementation("com.android.support:support-v4:27.1.1")
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
} else {
implementation 'org.webkit:android-jsc:+'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
#### `android/settings.gradle`:
rootProject.name = 'Project name'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
#### `MainApplication.java`:
package com.patrianap;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Project name";
}
}
#### `AndroidManifest.xml`:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
Click To Expand
**`react-native info` output:**
System:
OS: macOS 10.15.1
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 44.44 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.11.1 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
react: ^16.9.0 => 16.10.2
react-native: ^0.61.1 => 0.61.2
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [ ] Android
- [ ] **iOS** but have not tested behavior on Android
- [X] **Android** but have not tested behavior on iOS
- [ ] Both
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `N`
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase and Invertase on Twitter for updates on the library.Crashes can take a good while to come through. How long have you been waiting?
Tested it last night - like 12 hours ago - still no crashes shown.
Then tried testing it this morning.
Disabling Debugging in the emulator didnt help.
Dashboard shows:
Crash-free users - 100%
firebase crashlytics does not work in debug mode check it in release mode will work like a charm.
you can check it by using
firebase.crashlytics().crash()
thanks
There are other reasons as well. Please review this comment and the next one: https://github.com/invertase/react-native-firebase/issues/2534#issuecomment-530954622
I think this could be in the API documentation for the crash function itself, it comes up pretty frequently and the reasons for not showing are many. @iGoogledYouYesterday if the information here and in the linked comment help you, can you please please :pray: hit the "edit" button at the top right of the documentation page and maybe add a quick "what if my crash doesn't show up?" section with bullet points?
@reactexcel you just saved my week, we've been stuck with this for way too long 馃う鈥嶁檪
@reactexcel -> Thank you very much! This helped me A LOT. I could have been trying till the dawn.
In deed - once I did
cd android && ./gradlew bundleRelease
and then run it with
react-native run-android --variant=release
It started showing errors in the Crashlytics.
Maybe the idea would be to highlight this instruction in the Docs for Crashlytics.
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Most helpful comment
firebase crashlytics does not work in debug mode check it in release mode will work like a charm.
you can check it by using
firebase.crashlytics().crash()
thanks