【问题标题】:Crashlytics doesn't find my fabric.propertiesCrashlytics 找不到我的 fabric.properties
【发布时间】: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


【解决方案1】:

我在使用 fabric gradle plugin 1.25.4 时遇到了同样的问题,在将 fabric gradle 版本更新到 1.31.0 后似乎已修复

classpath 'io.fabric.tools:gradle:1.31.0'

感谢这个 stackoverflow 答案:https://stackoverflow.com/a/57206074/6671572

【讨论】:

    猜你喜欢
    • 2016-05-24
    • 1970-01-01
    • 2018-05-12
    • 2021-02-15
    • 1970-01-01
    • 2016-02-18
    • 2016-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多