[GH-ISSUE #17] Enhancement: add obfuscation rules and use minify #15

Open
opened 2026-02-28 14:24:03 +03:00 by kerem · 0 comments
Owner

Originally created by @vhaudiquet on GitHub (Jan 10, 2022).
Original GitHub issue: https://github.com/devgianlu/librespot-android/issues/17

If this app is here to showcase how librespot can be included in an Android app, i think it would be good to show the minimal proguard rules that should be added so that you can enable 'minify' for release configurations.

I went trough the hassle of testing that for my app, here are the rules i could come up with :

# The spotify librespot player needs an 'output class'
# for it's audio output ; we need to keep that
-keep class xyz.gianlu.librespot.android.sink.AndroidSinkOutput

# librespot needs reflexion to work internally
# Here we keep the classes it needs
-keep class xyz.gianlu.librespot.mercury.MercuryRequests$GenericJson
{
    <init>(com.google.gson.JsonObject); # method <init> i.e. constructor
}
-keep class xyz.gianlu.librespot.mercury.MercuryRequests$ResolvedContextWrapper
{
    <init>(com.google.gson.JsonObject); # method <init> i.e. constructor
}
-keep class com.spotify.** {*;}
-keep class xyz.gianlu.librespot.audio.decoders.** {*;}

(from https://github.com/vhaudiquet/BladePlayer/blob/master/app/proguard-rules.pro)

I did not check what was needed for the Android Native decoder or the Tremolo decoder as i don't use them in my app for now.

It appears to be working keeping only those classes, and it cuts in half my app size.
I hope it can be useful to other people, this is why i'm sharing this here (and i think it should be included in the project, either in the proguard rules file or in the readme/documentation)

Originally created by @vhaudiquet on GitHub (Jan 10, 2022). Original GitHub issue: https://github.com/devgianlu/librespot-android/issues/17 If this app is here to showcase how librespot can be included in an Android app, i think it would be good to show the minimal proguard rules that should be added so that you can enable 'minify' for release configurations. I went trough the hassle of testing that for my app, here are the rules i could come up with : ``` # The spotify librespot player needs an 'output class' # for it's audio output ; we need to keep that -keep class xyz.gianlu.librespot.android.sink.AndroidSinkOutput # librespot needs reflexion to work internally # Here we keep the classes it needs -keep class xyz.gianlu.librespot.mercury.MercuryRequests$GenericJson { <init>(com.google.gson.JsonObject); # method <init> i.e. constructor } -keep class xyz.gianlu.librespot.mercury.MercuryRequests$ResolvedContextWrapper { <init>(com.google.gson.JsonObject); # method <init> i.e. constructor } -keep class com.spotify.** {*;} -keep class xyz.gianlu.librespot.audio.decoders.** {*;} ``` (from https://github.com/vhaudiquet/BladePlayer/blob/master/app/proguard-rules.pro) I did not check what was needed for the Android Native decoder or the Tremolo decoder as i don't use them in my app for now. It appears to be working keeping only those classes, and it cuts in half my app size. I hope it can be useful to other people, this is why i'm sharing this here (and i think it should be included in the project, either in the proguard rules file or in the readme/documentation)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot-android#15
No description provided.