Android 添加崩溃报告框架以响应本机应用程序

Android 添加崩溃报告框架以响应本机应用程序,android,firebase,react-native,crashlytics,google-fabric,Android,Firebase,React Native,Crashlytics,Google Fabric,我已经尝试将Firebase和Fabric框架添加到我的react原生(android)应用程序中。我按照这些步骤成功地进行了设置,并测试了一个强制崩溃,但我无法获得JavaScript文件的崩溃报告。 我找到了以下链接: 但它仍然不起作用 我也试过了,我得到了视图和会话,但仍然没有关于崩溃的报告 Firebase和织物植入项目代码 app/build.gradle文件 apply plugin: "com.android.application" apply plugin: "io.fab

我已经尝试将Firebase和Fabric框架添加到我的react原生(android)应用程序中。我按照这些步骤成功地进行了设置,并测试了一个强制崩溃,但我无法获得JavaScript文件的崩溃报告。 我找到了以下链接:

但它仍然不起作用

我也试过了,我得到了视图和会话,但仍然没有关于崩溃的报告

Firebase和织物植入项目代码

app/build.gradle文件

apply plugin: "com.android.application"
apply plugin: "io.fabric"
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 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.sample2"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
 }
 splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // 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
        ext.enableCrashlytics = 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
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
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
        }

    }
}
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'
}
repositories {
 maven { url "https://jitpack.io" }
 maven { url "https://maven.fabric.io/public" }
 }
}
 dependencies {
compile("com.crashlytics.sdk.android:crashlytics:2.5.5@aar") {
 transitive = true;}
  implementation project(':react-native-fabric')
  implementation fileTree(dir: "libs", include: ["*.jar"])
  implementation "com.facebook.react:react-native:+"  // From node_modules
 implementation 'com.google.firebase:firebase-core:16.0.4'
  implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
 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)
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.android.tools.build:gradle:1.3.1"
    classpath "io.fabric.tools:gradle: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()
   }
 }
project build.gradle文件

apply plugin: "com.android.application"
apply plugin: "io.fabric"
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 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.sample2"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
 }
 splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // 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
        ext.enableCrashlytics = 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
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
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
        }

    }
}
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'
}
repositories {
 maven { url "https://jitpack.io" }
 maven { url "https://maven.fabric.io/public" }
 }
}
 dependencies {
compile("com.crashlytics.sdk.android:crashlytics:2.5.5@aar") {
 transitive = true;}
  implementation project(':react-native-fabric')
  implementation fileTree(dir: "libs", include: ["*.jar"])
  implementation "com.facebook.react:react-native:+"  // From node_modules
 implementation 'com.google.firebase:firebase-core:16.0.4'
  implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
 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)
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.android.tools.build:gradle:1.3.1"
    classpath "io.fabric.tools:gradle: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()
   }
 }
App.js

import React, {Fragment} from 'react';
import { SafeAreaView, StyleSheet, ScrollView, View,Text,StatusBar,} from 
'react-native';
 import Fabric from 'react-native-fabric';
 import Crashlytics from 'react-native-fabric-crashlytics';
import {  Header,  LearnMoreLinks,  Colors,  DebugInstructions, 
ReloadInstructions,} from 'react-native/Libraries/NewAppScreen';

 export default class App extends React.Component {

 componentWillMount(){
 var { Crashlytics } = Fabric;
Crashlytics.crash();

  }
 render() {
 return (
    <View style = {styles.container}>
       <Text>Open up App.js to start working on your app!</Text>
       <Text>Changes you make will automatically reload.</Text>
       <Text>Shake your phone to open the developer menu.</Text>
    </View>
 );
  }
 }

const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
  backgroundColor: Colors.white,
 },
 sectionContainer: {
 marginTop: 32,
 paddingHorizontal: 24,
},
  sectionTitle: {
 fontSize: 24,
 fontWeight: '600',
 color: Colors.black,
 },
  sectionDescription: {
 marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
 },
 footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
 });
import React,{Fragment}来自'React';
从导入{SafeAreaView,样式表,滚动视图,视图,文本,状态栏,}
“反应自然”;
从“react native Fabric”导入面料;
从“react native fabric Crashlytics”导入Crashlytics;
导入{标头、LearnMoreLink、颜色、调试说明、,
从'react native/Libraries/NewAppScreen'重新加载指令,};
导出默认类App扩展React.Component{
组件willmount(){
var{Crashlytics}=结构;
Crashlytics.crash();
}
render(){
返回(
打开App.js开始使用你的应用程序!
您所做的更改将自动重新加载。
摇动手机以打开开发者菜单。
);
}
}
const styles=StyleSheet.create({
滚动视图:{
背景颜色:颜色。颜色较浅,
},
发动机:{
位置:'绝对',
右:0,,
},
正文:{
背景颜色:Colors.white,
},
节容器:{
玛金托普:32,
水平方向:24,
},
章节标题:{
尺寸:24,
重量:'600',
颜色:颜色,黑色,
},
章节说明:{
玛金托普:8,
尺码:18,
fontWeight:'400',
颜色:颜色,
},
亮点:{
重量:'700',
},
页脚:{
颜色:颜色,
尺寸:12,
重量:'600',
填充:4,
paddingRight:12,
textAlign:'右',
},
});

我该怎么做才能让这次事故报告顺利进行?

Firebase和fabric无法协同工作。从项目中删除Fabric.properties文件,然后使应用程序崩溃

我有一个完整的崩溃分析演示:
更改firebase键并查看集成部分

您的代码是什么?我添加了@MajidlotfiniaRight的代码,firebase和Fabric无法一起工作,因此请确保不要在两个指令集之间混合任何指令。此链接对于react native+firebase crashlytics也可能有用: