ProGuard won't play nice with okhttp and I keep getting the following Warnings:
Warning:com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl Warning:com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.HttpURLConnectionImpl Warning:com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpsURLConnection: can't find referenced method 'long getContentLengthLong()' in program class com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpURLConnection Warning:com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpsURLConnection: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class com.squareup.okhttp.internal.huc.JavaApiConverter$CacheHttpURLConnection Warning:there were 4 unresolved references to program class members. Your input classes appear to be inconsistent. You may need to recompile the code. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
These are my proguard settings for okhttp and retrofit:
-dontwarn rx.** -dontwarn okio.** -dontwarn com.squareup.okhttp.* -dontwarn retrofit.appengine.UrlFetchClient -keep class retrofit.** { *; } -keepclasseswithmembers class * { @retrofit.http.* <methods>; } -keepattributes Signature -keepattributes *Annotation*
Could this have something to do with the changes to ProGuard in Android Studio 1.0?
I tried the answers to related questions but they only suggested to use the settings I already have.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With