ProGuard not working with okhttp

it works for me with this configs. use ** instead of * for all sub classes with encapsulated child packages

-dontwarn org.xmlpull.v1.**
-dontwarn com.squareup.**
-keep class com.squareup.** { *; }

OkHttp

-keepattributes Signature

-keepattributes Annotation

-keep class okhttp3.** { *; }

-keep interface okhttp3.** { *; }

-dontwarn okhttp3.**


This works for me:

You have to add to your proguard-rules.pro this two lines:

-keep class com.squareup.okhttp.** { *; }

-keep interface com.squareup.okhttp.** { *; }

Complete proguard-rules.pro file will look like:

-dontwarn rx.**

-dontwarn okio.**

-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }

-dontwarn retrofit.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

-keepattributes Signature
-keepattributes *Annotation*

Source: https://stackoverflow.com/a/24178851/4102045


I was finally able to solve this problem.

The warnings I encountered were actually meaningless and can be ignored.

Instead I forgot to not obfuscate my model classes:

-keep class com.example.datamodel.** { *; }

After this change everything worked fine.