【发布时间】:2017-06-27 02:27:11
【问题描述】:
我遇到了 Crashlytics 的问题。不知道我做错了什么。 我有两个 buildTypes 发布和调试,如下所示。 Gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'android-apt'
def AAVersion = '4.2.0'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// replace with the current version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apt {
arguments {
// you should set your package name here if you are using different application IDs
resourcePackageName "com.testapp"
}
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.testapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 55
versionName "5.2.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
shrinkResources true
ext.enableCrashlytics = true
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
debug {
applicationIdSuffix ".debug"
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url
"https://oss.sonatype.org/content/repositories/snapshots/"
}
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" }
}
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
我还集成了 Answers 来捕获事件。奇怪的是,Fabric Dashboard 中没有报告任何崩溃。首先我认为这可能是proguard的问题,所以我在下面添加了几行以确保,但仍然没有运气。不确定我是否需要为发布版本做更多的事情。
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
发布版本正在捕获并向我显示用户数量、事件等的所有数据,但没有崩溃。
我后来添加了 debug{ } buildType,以便在 Fabric 仪表板上将 debug 和 release 版本分开。
我不知道出了什么问题。
【问题讨论】:
-
如何在应用程序中初始化 Crashlytics 工具包?
-
@Sanoop:我已经在 Application 类中初始化了它。比如:Fabric.with(this, new Crashlytics());
-
它不适用于仅发布版本,对吧?
-
@Sanoop 是的,它不适用于发布。所以我添加了一个调试 buildType 并且调试崩溃被记录下来。只有我没有看到发布版本的任何崩溃
-
为了进行测试,可以将此行添加到您的发布构建类型并检查崩溃是否正在记录?
ext.enableCrashlytics = true
标签: android crashlytics