Keep annotated class in Proguard

Manfred Moser picture Manfred Moser · Jul 24, 2012 · Viewed 14.8k times · Source

I have a bunch of classes that use e.g. an @Singleton annotation like so

@Singleton
public class ImageCache

that I would like to keep. How can I configure a proguard -keep statement so it applies to all classes that have that annotation.

Btw in terms of context I need this for an app using Roboguice on Android, which is why I added the tags. Might help others.

Answer

Eric Lafortune picture Eric Lafortune · Jul 25, 2012

ProGuard is based on a java-like configuration with wild-cards. It does require fully qualified class names. This should work:

-keep @com.google.inject.Singleton public class *