What is a security rule for StringDef annotation in android?

public class AssetsHelper {

    @StringDef({ScreenDensity.XHDPI,ScreenDensity.HDPI, ScreenDensity.XXHDPI})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ScreenDensity {
        String HDPI = "HDPI";
        String XHDPI = "XHDPI";
        String XXHDPI = "XXHDPI";
    }
}

When I use the default pro-guard protection rule in the Android SDK tools folder, I get an error for ScreenDensity. What is a protection rule to keep this StringDef ScreenDensityfrom obfuscation?

+4
source share
2 answers

Try adding this proguard rule:

-keepclassmembers class ** {
  @your.package.AssetsHelper.ScreenDensity public *;
}
+2
source

StringDefis an annotation of the source conservation policy. Therefore, it will be automatically disabled in the compiled code.

"" , -, .

0

Source: https://habr.com/ru/post/1656347/


All Articles