【发布时间】:2018-03-02 13:11:47
【问题描述】:
我在 Android Studio 项目中安装了 Crashlytics 插件,但 gradle 任务 crashlyticsUploadDistributionDebug 没有添加到 gradle 任务中。 如何添加到 gradle 任务?
安装 Crashlytics 成功,但下面的命令失败。
$ ./gradlew assembleDebug crashlyticsUploadDistributionDebug
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
FAILURE: Build failed with an exception.
* What went wrong:
Task 'crashlyticsUploadDistributionDebug' not found in root project 'MyProject'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.02 secs
我的 build.gradle 设置如下。
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "my.app.id"
manifestPlaceholders = [appName:"@string/app_name", iconLabel:"@string/icon_label"]
minSdkVersion 16
targetSdkVersion 26
versionCode 20
versionName "2.0.0"
}
buildTypes {
debug {
debuggable true
applicationIdSuffix ".debug"
versionNameSuffix '-dev'
}
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
develop {
manifestPlaceholders = [appName:"@string/dev_app_name", iconLabel:"@string/dev_icon_label"]
buildConfigField "boolean", "DEV_ENV", "true"
buildConfigField "String", "XXX", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
staging {
manifestPlaceholders = [appName:"@string/stg_app_name", iconLabel:"@string/stg_icon_label"]
buildConfigField "boolean", "DEV_ENV", "true"
buildConfigField "String", "XXX", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
production {
buildConfigField "boolean", "DEV_ENV", "false"
buildConfigField "String", "XXX", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.code.gson:gson:2.7'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.google.android.gms:play-services-analytics:11.0.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.mcxiaoke.volley:library:1.0.16'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.lsjwzh:materialloadingprogressbar:0.5.5-RELEASE'
compile 'io.realm:realm-android:0.80.3'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.2'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.facebook.conceal:conceal:1.0.3@aar'
compile 'com.appsflyer:af-android-sdk:4.6.1@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
}
我不知道怎么了。
【问题讨论】:
-
参考本教程,这将对您有所帮助。 numetriclabz.com/…
-
你有机会分享你的 build.gradle 吗?我想看看 Crashlytics 和 Fabric 的配置方式是否有什么特别之处。
-
@Saneesh 安装 Crashlytics 成功,但是 gradle 任务 crashlyticsUploadDistributionDebug 没有添加到 gradle 任务中。
-
谢谢@tama。看起来您正在使用非常旧版本的插件。可以使用 1.24.2 的 Fabric gradle 插件和 2.6.8 的 Crashlytics 吗?尝试修改您的 build.gradle 并进行干净的构建。
-
您能否发布完整的 build.gradle(包括 buildTypes、flavors 等)并删除任何敏感数据?
标签: android android-gradle-plugin crashlytics google-fabric