1

我正在开发一个应用程序,当在命令行中使用 gradle 构建它时(“clean build”甚至“clean installRelease”),我遇到了 Crashlytics 无法启动的问题:

java.lang.RuntimeException: Unable to create application XXXXXXXX: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.core.CrashlyticsMissingDependencyException: 
This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.

在尝试了很多关于 SO 的东西之后,我发现如果我跑了:

./gradlew clean installRelease
./gradlew installRelease

我的应用程序启动没有任何问题。

这有点痛苦,因为我必须在发布之前构建应用程序两次(如果我忘记这样做,我正在发布一个无法使用的应用程序:/

我的 gradle 文件设置正确(至少,插件没有抱怨它),并且 gradle 是最新的(gradle 2.9,android plugin 1.5.0,crashlytics 2.5.4,...)

以下是我的 build.gradle 中的几行:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.20.1'
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'io.fabric'


android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    signingConfigs {
        std {
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "XXXXXXXXXXX"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.std
        }
        debug {
            signingConfig signingConfigs.std
        }
    }

    productFlavors {
        stubbed {
            buildConfigField "boolean", "STUBBED", "true"
        }
        real {
            buildConfigField "boolean", "STUBBED", "false"
        }
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.4@aar') {
        transitive = true;
    }
    compile 'com.google.android.gms:play-services-gcm:8.3.0'

    compile 'com.jakewharton:butterknife:7.0.1'
}

如果有人曾经遇到并解决过此类问题,我很想听听 :) 谢谢!

4

0 回答 0