proguard icon indicating copy to clipboard operation
proguard copied to clipboard

Skip or not full obfuscation from class depending of annotation variable.

Open marciox25 opened this issue 4 years ago • 1 comments

I have this annotation that I was using on yGuard to obfuscate my code:

@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
public @interface Keep {
    boolean applyToMembers() default true;
}

Is there a way to use this same annotated class with ProGuard, but do what it did on yGuard? Example: If an class had this annotation:

@Keep(applyToMembers = false)

When a class has this annotation with the parameter applyToMembers on false, then only the class name will be kept. And if it is true, the process will skip obfuscation for the full class (including fields and methods).

In case a class has the @Keep(applyToMembers = false), and there is a method or field with the same annotation above, that field/method would also be skipped from the obfuscation/shrinking process.

Is there a way I can achieve this same behavior but with ProGuard or would I need to work with multiple annotations?

marciox25 avatar Oct 23 '21 11:10 marciox25

Just faced a similar issue - how to skip obfuscation on annotated classes. It seems that ProGuard can't read annotation values, so multiple annotations might needed.

SNWCreations avatar Nov 23 '24 11:11 SNWCreations