【发布时间】:2018-01-26 14:20:43
【问题描述】:
我正在尝试在我的应用程序中设置 Crashlytics,但我收到消息 java.lang.IllegalArgumentException:无法初始化 Fabric,AndroidManifest.xml 中缺少 API 密钥。将以下标签添加到您的应用程序元素 但我不想将我的密钥放在 androidManifest 中,所以我必须创建 fabric.properties,对吗?我的设置到现在为止。
/app/fabric.properties 中的 Fabric.properties
apiKey=XXXXXXXXXXXXXXXXXX
在 Application 类的 OnCreate() 上初始化。
private void setupCrashlytics(){
CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());
}
在gradle中设置依赖
apply plugin: 'com.android.application'
apply plugin: 'idea'
apply plugin: 'witness'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
dataBinding.enabled = true
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.douglas"
minSdkVersion 14
targetSdkVersion 27
versionCode 31
versionName "0.4.4"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = false
}
debug {
debuggable true
minifyEnabled false
ext.enableCrashlytics = false
}
beta {
debuggable true
signingConfig signingConfigs.debug
ext.enableCrashlytics = true
}
}
sourceSets {
main {
jniLibs.srcDir file('jniLibs')
assets.srcDirs = ['assets']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:preference-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:gridlayout-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'
compile 'com.google.guava:guava:20.0'
compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0'
compile 'com.loopj.android:android-async-http:1.4.8'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.jsoup:jsoup:1.8.2'
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
transitive = true
}
}
【问题讨论】:
-
有没有机会链接到完整的 build.gradle?另外,您能否删除您的 API 密钥使其不公开?
-
@Alexizamerican 在这里,伙计!
-
谢谢!当您遇到该错误时,您正在运行什么 buildType?
-
您找到解决方案了吗?我也面临同样的问题。
-
这里也一样。有什么解决办法吗?
标签: android crashlytics