gradle generate error when minifying the code

妖精的绣舞 提交于 2019-12-11 11:34:24

问题


when i try to set the minifyEnabled to true and try to sync gradle file i receive the follwoing error:

Error:Cause: com/android/build/gradle/tasks/AndroidProGuardTask

why i am receiving this error and how to solve it, I cant enable proGaurd in Android Studio.

build.gradle:

buildTypes {
    debug {
        debuggable true
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

回答1:


are you using any external library files in your project? If yes, the you need to add -keep in the proguard-rules.pro file. I have added the following code to the file:

-keep public class org.jsoup.** {
    public *;
}

my proguard-rules.profile can be found here. You can also make sure the error is because of this by disabling the minifyEnabled to false in the proguard-rules.pro file.




回答2:


add this to your proguard

 -dontwarn package name of you library.**

in your case use package name of Jama

for example

-dontwarn org.slf4j.**
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**

if you can paste more error or stacktrace I will try to help more



来源:https://stackoverflow.com/questions/38203688/gradle-generate-error-when-minifying-the-code

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