I am trying to manually obfuscate my Android application (yes, I know, it's a pain) and for that I need to keep all the methods I implement yet also obfuscate them with ProGuard at the same time.
I have tried changing the config like this:
-keep class com.project.x.* {
}
But it kept all the class names and method names and still removed my unused code.
What can I do to solve this issue?
Thanks in advance!
Shrinking Options Specifies not to shrink the input. By default, ProGuard shrinks the code: it removes all unused classes and class members. It only keeps the ones listed by the various -keep options, and the ones on which they depend, directly or indirectly.
R8 is having a faster processing time than Proguard which reduces build time. R8 gives better output results than Proguard. R8 reduces the app size by 10 % whereas Proguard reduces app size by 8.5 %. The android app having a Gradle plugin above 3.4.
As CommonsWare explained, it seems unlikely that you want to keep unused methods and yet have their names obfuscated, but ProGuard supports it as follows:
-keepclassmembers,allowobfuscation class com.project.x.** {
<methods>;
}
This forcibly keeps all methods (but not all classes) in the specified package (and its subpackages), but still allows their names to be obfuscated.
Use keep option modifiers - see here
I think you'd do something like this:
-keep,allowoptimization class com.project.x.* {
}
But to quote the documentation: "This modifier is only useful for achieving unusual requirements."
Have you tried to reverse enginner to see that this is something you need to do? My impression of keep is that it will preserve the class as an entry point to the app, but that it doesn't stop it optimising and obfuscating the methods of those classes internally.
Maybe all you want is -keepnames
see that link above for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With