Skip to content

Any pusher-websocket-java version after 2.2.8 will crash when obfuscated with Proguard or R8 #333

@julioromano

Description

@julioromano

What is the issue?

Any pusher-websocket-java version after 2.2.8 will crash at runtime when obfuscated with Proguard or R8 returning:

Didn't receive all the fields expected from the ChannelAuthorizer, expected an auth and shared_secret.

What is the cause?

This is due to this change: #278

This PR changes the way the JSON is deserialized and now uses POJOs.
When obfuscating code using Proguard or R8 the POJOs will be obfuscated and their field names won't match those in the JSON anymore.

What are the possible solutions?

Adding @SerializedName annotation to all POJOs deserialized fields

OR

Including appropriate Proguard rules for consumers in src/main/resources/META-INF/proguard/pusherchannels.pro like other projects are doing (e.g. https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro )
Right now adding this single keep-all rule -keep class com.pusher.client.** { *; } does the job but of course you might want to add more strict rules to only avoid obfuscating classes used for JSON deserialization.

CC @pusher/mobile

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

    Issue actions