如何在我的React Native Android App中使用Crashlytics? [英] How do I use Crashlytics for my React Native Android App?
问题描述
我试图找出如何在我的React Native Android APP中使用Fabric中的Crashlytics。我按照Fabric主页上的步骤进行操作,并在build.gradle文件中添加了几行。但是构建总是会崩溃。
I am trying to figure out how to use Crashlytics from Fabric for my React Native Android APP. I followed the steps on the Fabric homepage and added some lines in my build.gradle files. But the builds always crash.
使用Crashlytics for React Native Android和使用Crashlytics进行Android Studio和Java开发是否有所不同?
Is there a difference using Crashlytics for React Native Android and Crashlytics for Native Android development using Android Studio and Java?
推荐答案
我以某种方式使它工作,但这可能不是完美的解决方案...
I got it working in some way, but it may not be the perfect solution...
1:将fabric / crashlytics添加到您的app / build.gradle-文件
(我的app / build.gradle中没有buildscript所以我只是把它包括在内。但是我不确定这是否好....)
1: Add fabric/crashlytics into your app/build.gradle - File (I didn´t have the buildscript in my app/build.gradle so i just included it. But i am not sure if this is good....)
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
// Add this directly under: apply plugin: "com.android.application"
apply plugin: 'io.fabric'
// and this directly under: apply from: "react.gradle"
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
// Last but not least add Crashlytics Kit into dependencies
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true
}
2:最重要的是,因为它没有被提及(或者我在任何地方都找不到),所以将Crashlytics和Fabric导入MainActivity:
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
3:在您的onCreate-方法中添加:
// Fabrics
Fabric.with(this, new Crashlytics());
完成此操作后,至少会得到由本机代码(Java)引起的Crashreports码)。通过JS-语法或类似原因引起的崩溃将不会得到通知。在那里,您将获得已知的RedBox:P
When you´ve done this, you will at least get Crashreports which are caused by native Code (Java Code). Crashes which are caused through JS - Syntax or similar wont be notified. There you will get the known RedBox :P
祝您好运!
这篇关于如何在我的React Native Android App中使用Crashlytics?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!