构建失败,应用程序:transformClassesAndResourcesWithProguardForRelease

Posted

技术标签:

【中文标题】构建失败,应用程序:transformClassesAndResourcesWithProguardForRelease【英文标题】:Build fails with app:transformClassesAndResourcesWithProguardForRelease 【发布时间】:2017-08-29 17:48:20 【问题描述】:

我最近将 android studios 更新到 2.3 版,将构建工具更新到 25.0.2、gradle 2.3.0 和 gradle distribution 3.3,现在我在构建项目时得到了这个。旧版本从来没有这个问题。

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
        at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: Job failed, see logs for details
        at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185)
        at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
        at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
        ... 20 more
Caused by: java.io.IOException: java.lang.NullPointerException
        at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:283)
        at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63)
        at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173)
        at com.android.builder.tasks.Job.runTask(Job.java:48)
        at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
        at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:225)
Caused by: java.lang.NullPointerException
        at proguard.optimize.info.NonEmptyStackReturnMarker.setReturnsWithNonEmptyStack(NonEmptyStackReturnMarker.java:102)
        at proguard.optimize.info.NonEmptyStackReturnMarker.markReturnWithNonEmptyStack(NonEmptyStackReturnMarker.java:95)
        at proguard.optimize.info.NonEmptyStackReturnMarker.visitSimpleInstruction(NonEmptyStackReturnMarker.java:72)
        at proguard.classfile.instruction.visitor.MultiInstructionVisitor.visitSimpleInstruction(MultiInstructionVisitor.java:88)
        at proguard.classfile.instruction.SimpleInstruction.accept(SimpleInstruction.java:218)
        at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:138)
        at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:110)
        at proguard.classfile.instruction.visitor.AllInstructionVisitor.visitCodeAttribute(AllInstructionVisitor.java:54)
        at proguard.classfile.attribute.visitor.MultiAttributeVisitor.visitCodeAttribute(MultiAttributeVisitor.java:245)
        at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
        at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:81)
        at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95)
        at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:92)
        at proguard.classfile.visitor.MultiMemberVisitor.visitProgramMethod(MultiMemberVisitor.java:92)
        at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:73)
        at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:516)
        at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47)
        at proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java:85)
        at proguard.classfile.ProgramClass.accept(ProgramClass.java:358)
        at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
        at proguard.optimize.Optimizer.execute(Optimizer.java:649)
        at proguard.ProGuard.optimize(ProGuard.java:328)
        at proguard.ProGuard.execute(ProGuard.java:127)
        at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:54)
        at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:254)
        ... 5 more


BUILD FAILED

【问题讨论】:

嗨@Sayed我也有同样的问题,给定的解决方案对我不起作用,你能帮忙吗,我问过同样的问题***.com/questions/45629710/… @Awadesh 抱歉,我不确定是否能提供帮助。升级 proguard 对我有用 :) 【参考方案1】:

有类似的问题,

-ignorewarnings

proguard-rules.pro 的末尾修复了它。

【讨论】:

【参考方案2】:

引用了类似的问题here。它似乎已在 proguard 5.3.3 中修复。

尝试使用以下命令将 proguard 升级到 5.3.3:

buildscript 
    configurations.all 
        resolutionStrategy 
            force 'net.sf.proguard:proguard-gradle:5.3.3'
        
    

【讨论】:

谢谢。这解决了问题 我也面临同样的问题,但没有解决我的问题,请您帮忙 build.gradle 脚本存在于项目的不同级别,请同时指定您的解决方案应应用于哪个级别 我刚刚在类路径中使用最新版本更新 build:gradle 并解决了问题。

以上是关于构建失败,应用程序:transformClassesAndResourcesWithProguardForRelease的主要内容,如果未能解决你的问题,请参考以下文章

android studio:失败:构建失败并出现异常

在颤振中构建应用程序 2 次后构建失败

应用程序调试 gradle 构建失败取决于目标设备

任务应用程序执行失败生成调试构建配置

Phonegap 构建错误:哦,天哪。您的构建失败

为 Android 构建电话间隙应用程序失败