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.71k stars 2.22k forks source link

[🐛] Apk builds with firebase_crashlytics_collection_enabled = false #4257

Closed sbatikeri closed 4 years ago

sbatikeri commented 4 years ago

Issue

Describe your issue here Recently I have implemented firebase in our project. I am continuously having multiple issues related to crashlytics. I am not constantly seeing crashes / non-fatal on dashboard. I use to see non-fatal errors for api failures but not now. After looking at the recent issues I have added following settings to firebase.json file. I did notice that in my apk manifest file I did see firebase_crashlytics_collection_enabled by default false but I see the crashes on dashboard. Can some tell me when will firebase_crashlytics_collection_enabled set to true.

{
"react-native": {
"crashlytics_disable_auto_disabler": true,
"crashlytics_debug_enabled": true,
"crashlytics_auto_collection_enabled": true,
"perf_auto_collection_enabled": true,
"analytics_auto_collection_enabled": true
}
}

image


Project Files

platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'Track' do

Pods for Track

rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils'

pod 'react-native-geolocation', path: '../node_modules/@react-native-community/geolocation'

pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec" pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired" pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety" pod 'React', :path => '../node_modules/react-native/' pod 'React-Core', :path => '../node_modules/react-native/' pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' pod 'React-Core/DevSupport', :path => '../node_modules/react-native/' pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon" pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon" pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' pod 'RNInputMask', :path => '../node_modules/react-native-text-input-mask/ios/InputMask'

pod 'Firebase/Analytics' pod 'Firebase/Crashlytics' pod 'Firebase/Performance'

target 'TrackQA' do end

target 'TrackUAT' do end

target 'TrackPROD' do end

target 'TrackTests' do inherit! :search_paths

Pods for testing

end

use_native_modules! end

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 playServicesVersion = "17.0.0" androidXAnnotation = "1.1.0" androidXBrowser = "1.0.0" } repositories { google() jcenter() } dependencies { classpath('com.android.tools.build:gradle:4.0.1') classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' classpath 'com.google.firebase:perf-plugin:1.3.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { mavenLocal() 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") }

    google()
    jcenter()
   maven { url 'https://jitpack.io' }
    //  maven {
    //     url 'https://maven.google.com/'
    //     name 'Google'
    // }
}

}

apply plugin: "com.android.application" apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.google.firebase.firebase-perf' import com.android.build.OutputFile

/**

project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ]

// project.ext.envConfigFiles = [ // debug: ".env", // release: ".env", // ]

apply from: "../../node_modules/react-native/react.gradle"

/**

/**

/**

/**

android { compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.Track"
    def authRedirectScheme
    project.env.each { key, value ->
       if(key == "APP_VERSION_CODE"){
         def appVersionCode = value.replaceAll("%", "\\\\u0025")  
         versionCode  appVersionCode.toInteger()
         println("APP_VERSION_CODE: $appVersionCode")
       }

       if(key == "VERSION"){
         def appVersionName = value.replaceAll("%", "\\\\u0025")  
         versionName  appVersionName
         println("versionName: $appVersionName")
       }

       if(key == "PING_AUTH_REDIRECT_SCHEME"){
            authRedirectScheme = value.replaceAll("%", "\\\\u0025")  
            println("PING_AUTH_REDIRECT_SCHEME: $authRedirectScheme")
       }
    }

    resValue "string", "build_config_package", "com.Track"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    multiDexEnabled true
    manifestPlaceholders = [
         appAuthRedirectScheme:  authRedirectScheme != null ? authRedirectScheme : "com.Track"
    ]
}

flavorDimensions "default"
productFlavors {
    dev { 
        dimension "default"
        applicationIdSuffix ".dev"
        versionNameSuffix "-dev"
        resValue "string", "app_name", "Track-Dev" 
    }
    qa { 
        dimension "default"
        applicationIdSuffix ".qa"
        versionNameSuffix "-qa"
        resValue "string", "app_name", "Track-Alpha"
    }
    uat { 
        dimension "default" 
        applicationIdSuffix ".uat"
        versionNameSuffix "-uat"
        resValue "string", "app_name", "Track-Beta"
    }
    prod { 
        dimension "default"
        versionNameSuffix ""
        resValue "string", "app_name", "Track"
    }
}

splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk true  // If true, also generate a universal APK
        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
        resValue "string", "app_name", "Track-Dev"
        firebaseCrashlytics {
            mappingFileUploadEnabled true
        }
    }

    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://facebook.github.io/react-native/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        shrinkResources enableProguardInReleaseBuilds
        zipAlignEnabled enableProguardInReleaseBuilds 
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        minifyEnabled true
        firebaseCrashlytics {
             mappingFileUploadEnabled true
        }
    }
}

// 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
                     println "VersionCode Override : ${output.versionCodeOverride}"
        }

    }
}

}

dependencies {

implementation fileTree(dir: "libs", include: ["*.jar"])
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'
implementation 'com.google.firebase:firebase-analytics:17.4.4'
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
implementation 'com.google.firebase:firebase-perf:19.0.8'

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

}

// 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"); apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle"); applyNativeModulesAppBuildGradle(project)

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.track" android:networkSecurityConfig="@xml/network_security_config" android:versionCode="1" android:versionName="1.0.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:largeHeap="true"
  android:theme="@style/AppTheme">

  <!-- You will only need to add this meta-data tag, but make sure it's a child of application -->

<meta-data android:name="com.google.android.geo.API_KEY" android:value="rrrrrQ91f-"/>

  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:screenOrientation="sensorPortrait"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustPan">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

Javascript

Click To Expand

#### `package.json`: { "name": "Track", "version": "0.0.1", "private": true, "scripts": { "ios": "react-native run-ios", "start": "react-native start", "android-clean": "echo 'CLEANING ...' && cd android/ && ./gradlew clean && cd ..", "android-build-all": "build_scripts/start_build_android.sh", "android-bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res", "android": "react-native run-android --variant=devDebug", "android-prod": "react-native run-android --variant=prodRelease", "android-qa": "react-native run-android --variant=qaRelease", "android-uat": "react-native run-android --variant=uatRelease", "ios-dev": "react-native run-ios --scheme Track", "ios-qa": "react-native run-ios --scheme TrackQA", "ios-uat": "react-native run-ios --scheme TrackUAT ", "ios-prod": "react-native run-ios --scheme TrackPROD", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "postinstall": "patch-package" }, "dependencies": { "@b9/react-native-autocomplete-search": "^1.2.0", "@react-native-community/async-storage": "^1.8.1", "@react-native-community/masked-view": "^0.1.6", "@react-native-community/push-notification-ios": "^1.5.0", "@react-native-firebase/analytics": "^7.6.2", "@react-native-firebase/app": "^8.4.2", "@react-native-firebase/crashlytics": "^8.4.4", "@react-native-firebase/messaging": "^7.8.6", "@react-native-firebase/perf": "^7.4.2", "@react-navigation/bottom-tabs": "^5.0.7", "@react-navigation/drawer": "^5.0.7", "@react-navigation/native": "^5.0.7", "@react-navigation/stack": "^5.0.8", "add": "^2.0.6", "axios": "^0.19.2", "axios-retry": "^3.1.2", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.2", "geolib": "^3.2.1", "google-libphonenumber": "^3.2.10", "haversine": "^1.1.1", "immutable": "^4.0.0-rc.12", "jwt-decode": "^2.2.0", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", "patch-package": "^6.2.2", "react": "16.9.0", "react-devtools": "^4.4.0", "react-dom": "^16.13.1", "react-jwt-store": "^1.7.0", "react-native": "0.61.5", "react-native-app-auth": "^5.1.2", "react-native-autocomplete-input": "^4.2.0", "react-native-config": "^0.12.0", "react-native-elements": "^1.2.7", "react-native-geocoder-reborn": "^0.9.0", "react-native-geolocation-service": "^4.0.0", "react-native-gesture-handler": "^1.6.1", "react-native-inappbrowser-reborn": "^3.4.0", "react-native-keyboard-aware-scroll-view": "^0.9.1", "react-native-maps": "0.27.1", "react-native-orientation-loading-overlay": "^0.1.6", "react-native-picker-select": "^6.6.0", "react-native-push-notification": "^5.1.0", "react-native-ratings": "^6.5.0", "react-native-reanimated": "^1.7.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.2.0", "react-native-scrolling-menu": "^0.1.1", "react-native-secure-key-store": "^2.0.9", "react-native-sendgrid": "^1.0.1", "react-native-sha256": "^1.3.6", "react-native-splash-screen": "^3.2.0", "react-native-text-input-mask": "^2.0.0", "react-native-timer": "^1.3.6", "react-native-vector-icons": "^6.6.0", "react-navigation": "^4.2.1", "react-navigation-stack": "^1.10.3", "react-redux": "^7.2.0", "react-swipeable-views-native": "^0.13.2", "react-use": "^13.27.1", "redux": "^4.0.5", "redux-devtools-extension": "^2.13.8", "redux-persist": "^6.0.0", "redux-persist-transform-immutable": "^5.0.0", "redux-saga": "^1.1.3", "redux-saga-jwt": "^1.0.4-beta.0", "redux-thunk": "^2.3.0", "toggle-switch-react-native": "^2.1.0" }, "devDependencies": { "@babel/core": "^7.9.0", "@babel/preset-env": "^7.9.0", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^0.0.5", "@types/jest": "^24.0.24", "@types/react-native": "^0.60.25", "@types/react-test-renderer": "16.9.1", "@typescript-eslint/eslint-plugin": "^2.12.0", "@typescript-eslint/parser": "^2.12.0", "babel-core": "^6.26.3", "babel-jest": "^25.1.0", "babel-preset-env": "^1.7.0", "eslint": "^5.16.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.56.0", "react-native-obfuscating-transformer": "^1.0.0", "react-test-renderer": "16.9.0", "remote-redux-devtools": "^0.5.16", "typescript": "^3.7.3" }, "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ] } } ```json # N/A ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `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? - [x ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **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:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


mikehardy commented 4 years ago

Something you've done to the formatting in the issue template has made it such that your code is not enclosed in triple-backticks, it's quite difficult to read

This may be of interest:

https://github.com/invertase/react-native-firebase/blob/9097f8e794f161f0c46bf1d54ae1e43386fbbb2c/packages/crashlytics/android/src/main/AndroidManifest.xml#L5-L8

https://github.com/invertase/react-native-firebase/blob/9097f8e794f161f0c46bf1d54ae1e43386fbbb2c/packages/crashlytics/android/src/main/java/io/invertase/firebase/crashlytics/ReactNativeFirebaseCrashlyticsInitProvider.java#L32-L63

sbatikeri commented 4 years ago

Thanks for answering my question and sorry screwing issue format.