gradle generate error when minifying the code

2019-07-23 15:22发布

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'
    }
}

2条回答
狗以群分
2楼-- · 2019-07-23 15:54

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

查看更多
【Aperson】
3楼-- · 2019-07-23 16:14

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.

查看更多
登录 后发表回答