使用gradle混淆打包
buildTypes { release { debuggable true minifyEnabled true //启用Proguard shrinkResources true //是否清理无用资源,依赖于minifyEnabled zipAlignEnabled true //是否启用zipAlign压缩 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } }
出现这样的错误
Error:Execution failed for task :transformClassesAndResourcesWithProguardForRelease'. > java.io.IOException: Please correct the above warnings first.
找到报warning的类都给他在你的proguard-rules.pro
混淆器文件中
添加代码-dontwarn 包名+类名.**
给取消掉warning就可以了,如果你不想那个类被混淆,那就添加代码:-keep class 包名+类名{*;}或者包名.**{*;}
# 环信 -keep class com.hyphenate.** {*;} -dontwarn com.hyphenate.** # 七牛 -keep class com.qiniu.**{*;} -keep class com.qiniu.**{public <init>();} -ignorewarnings -dontwarn com.alibaba.fastjson.** -dontwarn org.greenrobot.greendao.** -dontwarn org.apache.** -dontwarn org.codehaus.** -dontwarn java.nio.file.**