Search code examples
androidproguardbundling-and-minification

Why do I need to keep my source code in Proguard Rules to prevent crashing?


I tried to build and run my application with minifyEnabled and shrinkResources set to true. However, it kept on crashing and upon closer inspection, it was crashing on some of my classes and that I needed to keep these classes.

Why do I need to keep certain classes from obfuscation and not the other classes? Just need an idea of why this happens. Thank you!

Edit: The classes that cannot be minified were Serialized Objects


Solution

  • From my experience, key-value object need to excluded from obfuscation

    In my case, the problem is my model class and key obfuscated to a different name and string each build and make my cached data broken every time rebuild

    first build my model key obfuscated to "A", second build my model key obfuscated to "B"

    update: to exclude class from obfuscation check this post