Files
react-native-firebase/packages/app/android/firebase-json.gradle
Mike Diarmid c89ba48e92 [v6] Implement Crashlytics upgrade + required internals changes (#1958)
[crashlytics]

Fixes: #1643, #1848, #1964, #1920, #1884, #1783, #1966, #1940, #1447

Features/Bugs Todo:

  Capture JS Exceptions with stack traces automatically
  Capture Unhandled Promise Rejections with stack traces automatically
  [Android] .crash() not captured in debug due to RN RedBox; see #1921
  Support advanced user identifier features
  [Android] Enable Crashlyics NDK reporting by default (gist)
  Support toggling native crash logging off/on (e.g. disable in DEV)
  Support toggling JS crash logging off/on (e.g. disable in DEV)

  [ios] Static framework support for all modules
  [ios] Implement CocoaPods Firebase RN modules auto-loader script
  Implement firebase.json config loader; Android & iOS
  [tests] Fix false positive tests that catch errors (tests did not check that errors actually threw)
  [android] Cleanup manifest permissions for all modules
  [android] Implement Content provider base class
  [android] Investigate/fix issue where setDataCollectionDefaultEnabled is false by default in Firebase - it disables Crashlytics reporting
2019-03-13 17:07:21 +00:00

43 lines
1.3 KiB
Groovy

import groovy.json.JsonOutput
import groovy.json.JsonSlurper
String fileName = "firebase.json"
String jsonRoot = "react-native"
File jsonFile = null
File parentDir = rootProject.projectDir
for (int i = 0; i <= 3; i++) {
parentDir = parentDir.parentFile
jsonFile = new File(parentDir, fileName)
if (jsonFile.exists()) break
}
if (jsonFile != null && jsonFile.exists()) {
rootProject.logger.info ":${project.name} firebase.json found at ${jsonFile.toString()}"
Object json = null
try {
json = new JsonSlurper().parseText(jsonFile.text)
} catch (Exception ignored) {
rootProject.logger.warn ":${project.name} failed to parse firebase.json found at ${jsonFile.toString()}."
rootProject.logger.warn ignored.toString()
}
if (json && json[jsonRoot]) {
String jsonStr = JsonOutput.toJson(JsonOutput.toJson(json[jsonRoot]))
rootProject.logger.info ":${project.name} found react-native json root in firebase.json, creating firebase build config"
android {
defaultConfig {
buildConfigField "String", "FIREBASE_JSON_RAW", jsonStr
}
}
}
} else {
rootProject.logger.info ":${project.name} no firebase.json found, skipping"
android {
defaultConfig {
buildConfigField "String", "FIREBASE_JSON_RAW", '"{}"'
}
}
}