Skip to content

Enhancement: add obfuscation rules and use minify #17

Description

@vhaudiquet

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)

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions