Search code examples
androidandroid-fragmentsandroid-viewandroid-obfuscation

Why fragments and views doesn't obfuscate?


Although Fragment and View classes aren't android MainComponent and no reference of them in AndroidManifest.xml, but classes that extends Fragment or View don't change their name/package when minify is enabled and Proguard is working well.

Why they don't obfuscate?

PS1: The other codes obfuscate completely (change name/package/methods/attributes)

PS2: The above classes just obfuscate their methods and attributes. (Not name and package)


Solution

  • Why they don't obfuscate?

    They are frequently referenced by strings using reflection, such as in layout, menu, and navigation resources. If ProGuard renamed them, those strings would be invalid, and your app would crash. Hence, the default rules are set up to keep the names of those classes.