Crashlytics任务无法添加到gradle任务中(Crashlytics task cannot be added to gradle tasks)

编程入门 行业动态 更新时间:2024-10-09 09:24:45
Crashlytics任务无法添加到gradle任务中(Crashlytics task cannot be added to gradle tasks)

我在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; } }

我不知道出了什么问题。

I installed Crashlytics plugin to Android Studio project, but the gradle task crashlyticsUploadDistributionDebug is not added to gradle tasks. How can I add to gradle tasks?

Installing Crashlytics is successed, but the command below is failed.

$ ./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

My build.gradle setting is below.

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; } }

I don't know what is wrong.

最满意答案

我已经为productFlavors配置了开发,登台和生产,因此需要在命令中添加productFlavor。

以下是正确的命令。

./gradlew assembleDebug crashlyticsUploadDistribution [ flavor ] Debug

例如

$ ./gradlew assembleDebug crashlyticsUploadDistributionDevelopDebug Incremental java compilation is an incubating feature. :app:preBuild UP-TO-DATE :app:preDevelopDebugBuild UP-TO-DATE :app:checkDevelopDebugManifest :app:preDevelopReleaseBuild UP-TO-DATE :app:preProductionDebugBuild UP-TO-DATE :app:preProductionReleaseBuild UP-TO-DATE :app:preStagingDebugBuild UP-TO-DATE ・ ・ ・ :app:compileStagingDebugNdk UP-TO-DATE :app:compileStagingDebugSources :app:transformClassesWithDexForStagingDebug :app:mergeStagingDebugJniLibFolders :app:transformNativeLibsWithMergeJniLibsForStagingDebug :app:transformNativeLibsWithStripDebugSymbolForStagingDebug :app:processStagingDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForStagingDebug :app:validateSigningStagingDebug :app:packageStagingDebug :app:assembleStagingDebug :app:assembleDebug :app:crashlyticsUploadDistributionDevelopDebug Uploading /my_android_project_path/app/build/outputs/apk/app-develop-debug.apk to Crashlytics... BUILD SUCCESSFUL Total time: 23.897 secs

I have configure develop, staging and production to productFlavors, so need to add productFlavor to the command.

Below is correct command.

./gradlew assembleDebug crashlyticsUploadDistribution[flavor]Debug

e.g.

$ ./gradlew assembleDebug crashlyticsUploadDistributionDevelopDebug Incremental java compilation is an incubating feature. :app:preBuild UP-TO-DATE :app:preDevelopDebugBuild UP-TO-DATE :app:checkDevelopDebugManifest :app:preDevelopReleaseBuild UP-TO-DATE :app:preProductionDebugBuild UP-TO-DATE :app:preProductionReleaseBuild UP-TO-DATE :app:preStagingDebugBuild UP-TO-DATE ・ ・ ・ :app:compileStagingDebugNdk UP-TO-DATE :app:compileStagingDebugSources :app:transformClassesWithDexForStagingDebug :app:mergeStagingDebugJniLibFolders :app:transformNativeLibsWithMergeJniLibsForStagingDebug :app:transformNativeLibsWithStripDebugSymbolForStagingDebug :app:processStagingDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForStagingDebug :app:validateSigningStagingDebug :app:packageStagingDebug :app:assembleStagingDebug :app:assembleDebug :app:crashlyticsUploadDistributionDevelopDebug Uploading /my_android_project_path/app/build/outputs/apk/app-develop-debug.apk to Crashlytics... BUILD SUCCESSFUL Total time: 23.897 secs

更多推荐

本文发布于:2023-08-07 13:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464036.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:gradle   Crashlytics   task   tasks   added

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!