我遇到了proguard和volley库(https://github.com/mcxiaoke/android-volley)的问题。它在调试模式下很好地构建,但在发布时,它会出错。我已经在Stackoverflow上尝试了所有解决方案,但没有一个对我有用。这是错误
Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources UP-TO-DATE
:app:proguardRelease
Unexpected error while performing partial evaluation:
Class = [com/android/volley/toolbox/HttpClientStack]
Method = [performRequest(Lcom/android/volley/Request;Ljava/util/Map;)Lorg/apache/http/HttpResponse;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [com/android/volley/Request] (with 2 known super classes) and [com/android/volley/toolbox/HttpClientStack$HttpPatch] (with 1 known super classes))
Exception while processing task
java.lang.IllegalArgumentException: Can't find common super class of [com/android/volley/Request] (with 2 known super classes) and [com/android/volley/toolbox/HttpClientStack$HttpPatch] (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:609)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:567)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:271)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:188)
at proguard.optimize.evaluation.SimpleEnumUseChecker.visitCodeAttribute(SimpleEnumUseChecker.java:115)
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.optimize.evaluation.SimpleEnumUseChecker.visitProgramClass(SimpleEnumUseChecker.java:102)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:358)
at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
at proguard.optimize.Optimizer.execute(Optimizer.java:389)
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)
:app:dexRelease UP-TO-DATE
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of C:\Users\MyName\AndroidStudioProjects\AppName\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 37.612 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
这是我在proguard-rules.pro
中的设置-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**
答案 0 :(得分:1)
你必须保持齐射库如下:
-keep class com.android.volley.** { *; }
答案 1 :(得分:0)
在我的情况下,我在build.gradle中错过了这一行:
proguardFiles getDefaultProguardFile("proguard-android.txt")
默认规则包含规则
-dontoptimize
这是导致错误的主要原因