Keep annotated class in Proguard

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.

Answers


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 *

First define an annotation

public @interface DoNotStrip {}

Then put this in proguard.cfg:

-keep,allowobfuscation @interface com.something.DoNotStrip

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.something.DoNotStrip class *
-keepclassmembers class * {
    @com.something.DoNotStrip *;
}

Need Your Help

How to write to a text file from Pl/SQL, PLS error 00363

oracle plsql utl-file

I am trying to write to a file from a procedure:

Python: Split text after the second occurrence of character

python python-3.x

I need to split text before the second occurrence of the '-' character. What I have now is producing inconsistent results. I've tried various combinations of rsplit and read through and tried other