当我关闭 DexGuard 时,我的应用程序可以与 Crashlytics 完美运行。但是,当我添加以下配置来混淆我的代码时,应用程序在启动时卡住并出现黑屏。
这是build.gradle的相关部分
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'dexguard'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':MyProject')
compile('commons-validator:commons-validator:1.4.0') {
exclude group: 'commons-logging', module: 'commons-logging'
}
compile project(':android-maps-extensions')
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;
}
}
android {
publishNonDefault true
compileSdkVersion 23
buildToolsVersion "23"
compileOptions {
encoding "windows-1254"
}
defaultConfig {
applicationId "com.x.y"
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled true
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
dexOptions{
incremental true
javaMaxHeapSize "4g"
jumboMode true
}
android.enforceUniquePackageName = false
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
proguardFiles getDefaultDexGuardFile('dexguard-release.pro'),'dexguard-project.txt'
}
}
}
基础build.gradle文件:
buildscript {
repositories {
flatDir dirs: System.getenv('DEXGUARD_LIB')
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath ':dexguard'
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
dexguard-project.txt文件的相关部分:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-multidex
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
Logcat 控制台输出:
Could not find method com.crashlytics.android.Crashlytics.getInstance, referenced from method com.x.y.application.MyApplication.ʻ
Could not find method com.crashlytics.android.Crashlytics.getInstance, referenced from method com.x.y.application.MyApplication.ˏ
Could not find method com.crashlytics.android.Crashlytics.getInstance, referenced from method com.x.y.application.MyApplication.ᐝ
Starting window AppWindowToken{4518e2c0 token=Token{43255cd8 ActivityRecord{42d2a290 u0 com.x.y.tst/com.x.y.activity.start.FirstActivity t369}}} timed out
我实际上在用 Crashlytics.getInstance 做什么:
Crashlytics.getInstance().core.setString("ENVIRONMENT", "TEST");
我在构建日志中没有看到任何警告或错误。任何人都知道是什么导致了这个问题?
提前致谢!