2

There is one line in the default proguard configuration of android sdk:

-keepattributes *Annotation*

According to Proguard Manual, this line equals to:

-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,RuntimeVisibleTypeAnnotations,RuntimeInvisibleTypeAnnotations,AnnotationDefault

In my opinion, maybe the configuration below is enough:

-keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeVisibleTypeAnnotations,AnnotationDefault

Have I missing something? Why the recommend configuration keep all this things?

Shaw
  • 1,445
  • 16
  • 21

1 Answers1

4

No, your observation is correct, the following configuration would be more correct imho:

-keepattributes RuntimeVisible*Annotation*,AnnotationDefault

Most people probably don't care about the subtle difference between runtime visible and invisible annotations, but there is no specific reason to keep runtime invisible annotations.

Edit: the above applies for Android applications only. If you are building an Android library, you should stick to -keepattributes *Annotation*.

btw. DexGuard (commercial variant of ProGuard) uses the updated configuration that I suggested above.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
  • **applies for Android applications only. If you are building an Android library, you should stick to -keepattributes *Annotation\*** -- Thank you for pointing this out ! – Shaw Nov 01 '16 at 06:03