My favorites | Sign in
Project Home
Using proguard to reduce your application's footprint
Updated Sep 23, 2011 by


Storage space on android devices can be heavily constrained, particularly for users of the older generation of devices. The guice library isn't small, but we can reduce its footprint by using proguard to remove unnecessary classes and methods.

Proguard Configuration

Make sure you're using the SDK tools release 8 or later and visit Then use a configuration like the following::

-target 1.6
-dump ../bin/class_files.txt
-printseeds ../bin/seeds.txt
-printusage ../bin/unused.txt
-printmapping ../bin/mapping.txt 

# The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. 
-optimizations !code/simplification/arithmetic 

-keep public class * extends 
-keep public class * extends 
-keep public class * extends 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider
-keep class
-keepclassmembers class * { <init>(...);
# There's no way to keep all @Observes methods, so use the On*Event convention to identify event handlers
-keepclassmembers class * { 
    void *(**On*Event); 
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
-keep public class roboguice.**


If proguard is erroneously stripping out any classes you need, chances are you'll need to add some additional -keep directives to your config.txt. Consult the proguard manual for more details.

Further links

Look at this blog post on how to make obfuscation to work and some more tips.

Powered by Google Project Hosting