错误:任务“:app:transformClassesWithAndroidGradleClassShrinkerForDebug”执行失败
Posted
技术标签:
【中文标题】错误:任务“:app:transformClassesWithAndroidGradleClassShrinkerForDebug”执行失败【英文标题】:Error:Execution failed for task ':app:transformClassesWithAndroidGradleClassShrinkerForDebug' 【发布时间】:2017-12-18 04:58:57 【问题描述】:问题
当我尝试构建我的项目时出现此错误
错误:任务执行失败 ':app:transformClassesWithandroidGradleClassShrinkerForDebug'.
在收缩过程中发现警告,请使用-dontwarn 或-ignorewarnings 来抑制它们。
我的文件
应用构建.gradle
apply plugin: 'com.android.application'
android
compileSdkVersion 26
buildToolsVersion "26.0.0"
dexOptions
maxProcessCount = 2
javaMaxHeapSize = "2g"
dataBinding
enabled = true
packagingOptions
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/SearchFilter.properties'
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
// as noted by @Vishnuvathsan you may also need to include
// variations on the file name. It depends on your dependencies.
// Some other common variations on notice and license file names
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
defaultConfig
applicationId "com.mt.moviesiwanttowatch"
minSdkVersion 19
targetSdkVersion 26
versionCode 4
versionName "1.2"
multiDexEnabled true
buildTypes
release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debug
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Optional: see how to use the utility.
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
implementation "com.android.support:support-v13:26.0.0-beta2"
implementation 'com.android.support:design:26.0.0-beta2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta2'
implementation 'com.android.support:cardview-v7:26.0.0-beta2'
implementation 'com.google.android.gms:play-services-analytics:11.0.2'
implementation 'com.allattentionhere:fabulousfilter:0.0.2'
implementation 'com.nightonke:boommenu:2.1.0'
implementation 'com.github.Commit451:QuickActionView:2.0.0'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.nononsenseapps:filepicker:4.1.0'
implementation 'net.simonvt.schematic:schematic:0.7.0'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.1'
implementation 'com.ramotion.cardslider:card-slider:0.1.0'
implementation 'org.jsoup:jsoup:1.10.3'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
implementation "net.dean.jraw:JRAW:0.9.0"
implementation 'com.gordonwong:material-sheet-fab:1.2.1'
implementation 'com.github.bumptech.glide:glide:4.0.0-RC1'
implementation('com.google.android:flexbox:0.3.0')
exclude group: 'com.android.support'
implementation 'me.drozdzynski.library.steppers:steppers:0.4.0-SNAPSHOT'
implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
implementation 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
implementation 'com.afollestad.material-dialogs:core:0.9.4.5'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.github.jetradarmobile.desertplaceholder:desertplaceholder:1.2.3'
implementation 'com.github.rubensousa:gravitysnaphelper:1.2'
annotationProcessor 'com.android.databinding:compiler:2.3.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.7.0'
项目 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
repositories
jcenter()
maven url 'https://maven.google.com'
dependencies
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
classpath 'com.google.gms:google-services:3.0.0'
allprojects
repositories
jcenter()
maven url "https://jitpack.io"
maven url "https://maven.google.com"
maven url "https://oss.sonatype.org/content/repositories/snapshots/"
task clean(type: Delete)
delete rootProject.buildDir
和 proguard-rules.pro
# Add project specific ProGuard rules here.
# By defaulto, the flags in this file are appended to flags specified
# in C:\Users\CM\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the javascript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview
# public *;
#
-keep class io.codetail.animation.arcanimator.** *;
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$**
**[] $VALUES;
public *;
问题
如何修改我的文件来解决这个问题?
【问题讨论】:
你需要在proguard-rules.pro
的所有第三方库中添加-dontwarn或-ignorewarnings你可以在他们的docs/wiki页面上找到描述
@StanislavBondar 你能举例说明如何在 proguard 中编写这个吗?我以前没用过这个
您可以在这里找到解决方案:***.com/questions/47893266/…
【参考方案1】:
-
删除
multiDexEnabled true
、shrinkResources true
、useProguard false
将minifyEnabled true
更改为minifyEnabled false
希望这会有所帮助。
【讨论】:
【参考方案2】:更改buildTypes->debug->minifyEnabled=false
【讨论】:
以上是关于错误:任务“:app:transformClassesWithAndroidGradleClassShrinkerForDebug”执行失败的主要内容,如果未能解决你的问题,请参考以下文章
Visual Studio 错误:“无法激活后台任务。后台任务激活失败。”