classes.jar not found after using ProGuard in Android studio

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 03:24:20

问题


I have enabled minifyEnabled true in build.grade .

[...]
            Information:Gradle tasks [:app:assembleRelease]
            Warning:com.caverock.androidsvg.SVGImageView: can't find referenced class com.caverock.androidsvg.R$styleable
            Warning:com.caverock.androidsvg.SVGImageView: can't find referenced class com.caverock.androidsvg.R
            Warning:there were 3 unresolved references to classes or interfaces.
                     You may need to add missing library jars or update their versions.
                     If your code works fine without the missing classes, you can suppress
                     the warnings with '-dontwarn' options.
                   (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
            Exception while processing task 
            java.io.IOException: Please correct the above warnings first.
                at proguard.Initializer.execute(Initializer.java:473)
                at proguard.ProGuard.initialize(ProGuard.java:233)
                at proguard.ProGuard.execute(ProGuard.java:98)
                at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
                at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:137)
                at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:113)
                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
            :app:validateExternalOverrideSigning
            :app:packageRelease FAILED
            Error:Execution failed for task ':app:packageRelease'.
            > Unable to compute hash of /Users/sanjay/Desktop/android_project/RestaurantApp/app/build/intermediates/classes-proguard/release/classes.jar
            Information:BUILD FAILED
[...]

回答1:


I had the same issue and read somewhere a workaround to this issue and it was to disable minifyEnabled, generate signed APK.

buildTypes {
    release {
        minifyEnabled false
        shrinkResources true
        proguardFiles 'proguard-project.txt'
    }

I never face this issue before updating buildTool to 23.0.

Also, with this newer version, you need to add this to your Progaurd.txt file.

-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**

Hope this helps to resolve your issue too.



来源:https://stackoverflow.com/questions/32798394/classes-jar-not-found-after-using-proguard-in-android-studio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!