问题
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