Skip to content

ProGuard and Third Party Libraries - a Strategy

May 22nd, 2015 - Software(1 min)

Today I tried to compile my app for release with proguard. Previously, I skipped proguard, but now I wanted a lean package :). Soon, I got into a bit of a mess, because I noticed I have quite a few libs which need custom proguard rules. So, I ended up with one proguard file per library, included in a master proguard-rules.pro.

My current structure, as it stands is:

$ list-structure
-\
  + build.gradle
  + ...
  + proguard-rules.pro
  + proguard-com.jakewharton.butterknife.txt
  + proguard-com.squareup.retrofit.txt
  - proguard-com.mixpanel.txt

My proguard-rules.pro file is:

# Add project specific ProGuard rules here.
# ...
-include proguard-com.jakewarthon.butterknife.txt
-include proguard-com.squareup.retrofit.txt
-include proguard-com.mixpanel.txt

This is quite simple to manage and allows me not to modify the main file each time I have a change.

Note: Configurations for each library are already online.

Share on
Reddit
Linked in
Whatsapp

A little experiment: