Android使用gradle build with" minifyEnabled true"遇到错误,

时间:2015-11-10 08:53:51

标签: android android-studio gradle

这是我的错误信息:

Unexpected error while performing partial evaluation:
  Class       = [org/apache/log4j/chainsaw/Main]
  Method      = [<init>()V]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/NoClassDefFoundError] (with 5 known super classes) and [org/apache/log4j/chainsaw/LoadXMLAction] (with 1 known super classes))
Exception while processing task 
java.lang.IllegalArgumentException: Can't find common super class of [java/lang/NoClassDefFoundError] (with 5 known super classes) and [org/apache/log4j/chainsaw/LoadXMLAction] (with 1 known super classes)
        at proguard.evaluation.value.TypedReferenceValue.findCommonClass(TypedReferenceValue.java:441)
        at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:277)
        at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:201)
        at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:298)
        at proguard.evaluation.Variables.generalize(Variables.java:136)
        at proguard.evaluation.TracedVariables.generalize(TracedVariables.java:118)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:690)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:594)
        at proguard.optimize.evaluation.PartialEvaluator.visitExceptionInfo(PartialEvaluator.java:1079)
        at proguard.classfile.visitor.ExceptionHandlerFilter.visitExceptionInfo(ExceptionHandlerFilter.java:67)
        at proguard.classfile.attribute.CodeAttribute.exceptionsAccept(CodeAttribute.java:186)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateExceptionHandlers(PartialEvaluator.java:1019)
        at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:574)
        at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:271)
        at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:188)
        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.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.ClassAccessFilter.visitProgramClass(ClassAccessFilter.java:67)
        at proguard.classfile.ProgramClass.accept(ProgramClass.java:358)
        at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
        at proguard.optimize.Optimizer.execute(Optimizer.java:462)
        at proguard.ProGuard.optimize(ProGuard.java:328)
        at proguard.ProGuard.execute(ProGuard.java:127)
        at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
        at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
        at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
        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:227)
        at java.lang.Thread.run(Thread.java:745)
:mainAPlication:shrinkReleaseMultiDexComponents FAILED

如果我订     minifyEnabled true 这个错误来了, 如果我订      minifyEnabled flase 我的proguardtask工作正常,

这是我的proguard.cfg文件:

-optimizationpasses 1
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontshrink
-verbose
-microedition
-ignorewarnings
-keepattributes InnerClasses,Signature
-keepattributes *Annotation*

所以,我不知道这个错误是如何发生的,这看起来是因为minifyEnabled工作错误, 任何身体都遇到同样的问题。

当我在proguard.cfg中添加此行时,我的构建工作

-dontoptimize

但我不知道导致错误的原因

1 个答案:

答案 0 :(得分:0)

这可能是一个外部图书馆 我挖了这个 http://sohu.io/questions/1918042/proguard-cant-find-any-super-classes  我确实有这样的情况:

由于编译包含Log4J的库,Proguard无法构建。获取该库的所有者以删除log4j并对其进行调用是我要采取的方法。特别是对于生产,因为proguard确实应该用于生产/发布场景......