I enabled proguard for my release build and when I ran the project, I get these warnings and errors . Here is my buildTypes
block:
buildTypes {
release {
minifyEnabled true
//shrinkResources true
signingConfig signingConfigs.myConfig
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
The build message was too long to post here so have put external link. What is the reason for these warnings? Is there something I have done wrong? How can I fix this?
Each library mentioned in the warnings has its' own proguard rules which you have to put in your proguard-rules.pro. For example you can find ButterKnife's rules at http://jakewharton.github.io/butterknife/ "Proguard" section.
for any external library that you are using you need to add rules in your proguard.pro file.
For example in my project these are the proguard rules I added for retrofit and okhttp
# Retrofit 1.X
-keep class com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.**
-dontwarn rx.**
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
These rules are taken from
So you need to check similarly for each library what are the rules to be added.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.