Skip to content

What is OkHttp3 new proguard rules? #2230

Closed
@TheStar4Fate

Description

@TheStar4Fate

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

this is old version proguard rules

Activity

JakeWharton

JakeWharton commented on Jan 12, 2016

@JakeWharton
Collaborator

Change com.squareup.okhttp to okhttp3 in each.

added a commit that references this issue on Jan 26, 2016
ThomasSunderland

ThomasSunderland commented on Apr 8, 2016

@ThomasSunderland

Question: Isn't there an asterisk missing before the semicolon in the line...

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

ganeshkrishnan1

ganeshkrishnan1 commented on Apr 21, 2016

@ganeshkrishnan1

@ThomasSunderland

Yes that's correct. It should be

-keep class com.squareup.okhttp3.** {
*;
}
swankjesse

swankjesse commented on Apr 21, 2016

@swankjesse
Collaborator

(The package name is okhttp3 with no com.squareup prefix.)

wingsum93

wingsum93 commented on Apr 21, 2016

@wingsum93

OkHttp3

-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.* { ; }
-keep interface okhttp3.
* { ; }
-dontwarn okhttp3.

it is all corect for okhttp3

JakeWharton

JakeWharton commented on Apr 21, 2016

@JakeWharton
Collaborator

Those rules are massively over matching. As far as I can tell you don't
need any ProGuard rules for OkHttp.

On Thu, Apr 21, 2016, 5:08 AM eric ho notifications@github.com wrote:

-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.* {
; } -keep interface okhttp3.* {
; } -dontwarn okhttp3.

it is all corect for okhttp3


You are receiving this because you modified the open/close state.

Reply to this email directly or view it on GitHub
#2230 (comment)

mfaust35

mfaust35 commented on May 24, 2016

@mfaust35

I do get warnings using OkHttp3 & ProGuard :
(with gradle : compile 'com.squareup.okhttp3:okhttp:3.2.0' & compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0')

Warning: okhttp3.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getContentLengthLong()' in program class okhttp3.internal.huc.HttpURLConnectionImpl
Warning: okhttp3.internal.huc.HttpsURLConnectionImpl: can't find referenced method 'long getHeaderFieldLong(java.lang.String,long)' in program class okhttp3.internal.huc.HttpURLConnectionImpl

Which is "kind of normal" since in package okhttp3/internal/huc on branch okhttp_32, the class HttpsURLConnectionImpl.java has some strange code line 75 : method getContentLengthLong() exist neither in HttpURLConnectionImpl.java, nor in DelegatingHttpsURLConnection.java.
It may be related to this other issue?

Anyway, in my case, ignoring these 2 warnings with -dontwarn okhttp3.internal.huc.HttpURLConnectionImpl seems to be sufficient. I do get some other warnings with okio though (about some classes in package java.nio.file).

peterbetos

peterbetos commented on Jul 29, 2016

@peterbetos

Here's the correct format:

-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**
JakeWharton

JakeWharton commented on Jul 29, 2016

@JakeWharton
Collaborator

Those rules are crazy. You might as well just turn off ProGuard if you're
going to keep 100% of libraries.

On Thu, Jul 28, 2016, 6:31 PM Pier Betos notifications@github.com wrote:

Here's the correct format:

-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.* { ; }
-keep interface okhttp3.
* { ; }
-dontwarn okhttp3.

-dontwarn okio.**


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#2230 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEERig3dOGwSwEv2PDTBwTEgj9pewJks5qaUnHgaJpZM4HC_NG
.

peterbetos

peterbetos commented on Jul 29, 2016

@peterbetos

Fine, we can just use the following then:

-dontwarn okhttp3.**
-dontwarn okio.**

Edit: It worked, even with proguard-android-optimize.txt used. But it's odd that the class names are not obfuscated though when I pass it via ClassyShark.

screen shot 2016-07-30 at 9 27 30 am

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JakeWharton@swankjesse@BoD@ThomasSunderland@peterbetos

        Issue actions

          What is OkHttp3 new proguard rules? · Issue #2230 · square/okhttp