How to enforce updated proguard rule on app update?

Hi Team ,

I have an app with initial version having proguard rule .

          minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

After the app release to play store I found that some of the proguard rules are missing, so I added some more rules and released the app.

While testing I found that app update is not enforcing the updated proguard rule . Once I uninstall / install (fresh install) app then the updated proguard rule started getting effective.

Also if I delete the app user data then also the new proguard rule was effective.

Question : Is there any specific instruction to be followed to apply the updated proguard rule on app update?

Hi @Abhishek_Singh ,

In general, when you change a -keep rule in your ProGuard configuration you need to rebuild and update or re-install the app.

What may have happened here is that ProGuard obfuscated field names for classes you serialize and save somewhere (user data). In every build, the names of these fields will change and this may introduce issues across various updates since the app cannot access the earlier saved data anymore. Therefore, it’s important to preserve (-keep) class names ad the names of their members if you serialize them e.g. models.

Best regards,

Jonas

1 Like