invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

🔥 Crashlytics is not showing crash for android #2540

Closed abdullahbayram closed 5 years ago

abdullahbayram commented 5 years ago

Hi all! I am having an issue with Crashlytics on Android.

Issue

I've setup library with cloud messaging, notification and crashlytics on RN 60.5. Notifications works fine on Ios and Android. I can see ios crashes on console but can't see android crashes. In addition, firebase.crashlytics().crash() func works fine on both platform.

Project Files

iOS

Click To Expand Works fine

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [x] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" } repositories { google() jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath("com.android.tools.build:gradle:3.4.1") classpath 'com.google.gms:google-services:4.2.0' classpath ("io.fabric.tools:gradle:1.28.1") } } allprojects { repositories { mavenLocal() maven { url("$rootDir/../node_modules/react-native/android") } maven { url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() } } apply plugin: 'com.google.gms.google-services' // N/A ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: "io.fabric" import com.android.build.OutputFile project.ext.react = [ entryFile: "index.js", enableHermes: false, ] apply from: "../../node_modules/react-native/react.gradle" def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = 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.dismoni.dismoni" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 13 versionName "1.2.0" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } applicationVariants.all { variant -> variant.outputs.each { output -> 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 } } } packagingOptions { pickFirst '**/armeabi-v7a/libc++_shared.so' pickFirst '**/x86/libc++_shared.so' pickFirst '**/arm64-v8a/libc++_shared.so' pickFirst '**/x86_64/libc++_shared.so' pickFirst '**/x86/libjsc.so' pickFirst '**/armeabi-v7a/libjsc.so' } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules // Firebase dependencies implementation "com.google.android.gms:play-services-base:17.0.0" implementation "com.google.android.gms:play-services-gcm:17.0.0" implementation 'com.google.firebase:firebase-core:17.0.0' implementation 'com.google.firebase:firebase-messaging:19.0.1' implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') { transitive = true } // Share Extension if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } 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' // N/A ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'dismoni' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' // N/A ``` #### `MainApplication.java`: ```java package com.dismoni.dismoni; import android.app.Application; import android.util.Log; import com.facebook.react.PackageList; import com.facebook.hermes.reactexecutor.HermesExecutorFactory; import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.ReactApplication; import com.reactnativecommunity.webview.RNCWebViewPackage; import com.reactnativecommunity.netinfo.NetInfoPackage; import com.reactnativecommunity.asyncstorage.AsyncStoragePackage; import io.invertase.firebase.RNFirebasePackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.util.List; import io.invertase.firebase.RNFirebasePackage; import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage; import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); packages.add(new RNFirebaseMessagingPackage()); packages.add(new RNFirebaseNotificationsPackage()); packages.add(new RNFirebaseCrashlyticsPackage()); packages.add(new RNFirebaseAnalyticsPackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } } // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz Memory: 633.29 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 23, 25, 26, 27, 28 Build Tools: 23.0.1, 24.0.1, 25.0.1, 25.0.2, 25.0.3, 26.0.3, 27.0.3, 28.0.3, 29.0.2 System Images: android-23 | Intel x86 Atom, android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `~5.5.6` - **`Firebase` module(s) you're using that has the issue:** - `Crashlytics` - **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]

mikehardy commented 5 years ago

Interesting - quick thoughts:

    implementation platform("com.google.firebase:firebase-bom:22.0.0")
    implementation "com.google.firebase:firebase-core"
    implementation "com.google.firebase:firebase-auth"
    implementation "com.google.firebase:firebase-analytics"
    implementation "com.google.firebase:firebase-perf"
    implementation "com.google.firebase:firebase-config"
    implementation "com.google.firebase:firebase-functions"
    implementation "com.google.firebase:firebase-storage"
    implementation "com.google.firebase:firebase-dynamic-links"
    implementation "com.google.firebase:firebase-firestore"
    implementation "com.google.firebase:firebase-messaging"
    implementation 'com.crashlytics.sdk.android:crashlytics'

... and you should also upgrade the the google plugin and fabric plugin etc

abdullahbayram commented 5 years ago

I will also need analytics but i haven't setup it properly yet because of android crashlytics problem. Today I saw five crash occurred between 03.00 pm and 06.00 pm yesterday. However, these crashes was not seen yesterday at same the time. I had just updated my dependencies according to https://firebase.google.com/support/release-notes/android before the crashes seen on firebase console. Thanks a lot

mikehardy commented 5 years ago

Wow, so it seems it was just really slow - that is true sometimes. Hard to debug these indeterminate timing issues. Glad it worked though

LucasGarcez commented 5 years ago

Crashylitcs has two types of events. Crash and Non-fatal. In my case the only ones reported were Non-fatal. In order to report Crash events it is necessary to reopen the application so that firebase can send the report.

But on android the app doesn't report Crash type events with debug APK (this APK that is used by react-native run-android command, even if you're not in React Native debug mode) so on Android you need generate an apk release via the ./gradlew assembleRelease command in the "android" folder.

This command will generate a release apk in the android\app\build\outputs \apk\release folder install the .apk file on the device and crash, then reopen without crashing. Wait about 5 minutes for the crash report to appear on the Firebase console.

JeandeCampredon commented 4 years ago

Thanks @LucasGarcez, might be worth to add it to the documentation

tareqdayya commented 4 years ago

Please add it to the docs. I spent a good few hours trying to figure out why it wasn't reporting crashes.

mikehardy commented 4 years ago

There is an edit link at the top of every documentation page - github makes the PR process for documentation updates really fast + painless - it handles all the fork/clone/create PR stuff so it's just a couple of forms (one of which is you making the change) and that's it

tareqdayya commented 4 years ago

There is an edit link at the top of every documentation page - github makes the PR process for documentation updates really fast + painless - it handles all the fork/clone/create PR stuff so it's just a couple of forms (one of which is you making the change) and that's it

@mikehardy on it.