0

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?

Amit Tiwari
  • 3,684
  • 6
  • 33
  • 75

2 Answers2

1

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.

1

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

https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-square-retrofit.pro

So you need to check similarly for each library what are the rules to be added.

Ramesh
  • 1,287
  • 1
  • 9
  • 14