我正在尝试在我的应用程序中设置Crashlytics但是我收到消息 java.lang.IllegalArgumentException:Fabric无法初始化,AndroidManifest.xml中缺少API密钥。将以下标记添加到Application元素,但我不想将我的密钥放在androidManifest中,所以我必须创建fabric.properties,对吧?我的设置到现在为止。
/app/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
}
}
答案 0 :(得分:0)
我遇到了与 fabric gradle插件1.25.4 相同的问题,该问题在将fabric gradle版本更新为1.31.0之后似乎已得到解决
classpath 'io.fabric.tools:gradle:1.31.0'
感谢这个stackoverflow答案:https://stackoverflow.com/a/57206074/6671572