How to identify which optimization is breaking my app?

I’m having an issue with ProGuard making changes that cause my app to crash within 3rd party native code specifically just on Android 4.x.

I’ve found that setting the following rule resolves the issue:

-dontoptimize

This obviously suggests that the issue is somewhere in the optimisations, so I thought I’d try narrowing down specifically on which one it is. I then removed that line and used this instead:

-optimizations !library/,!class/,!field/,!method/,!code/*

My expectation was that the result would be the same - as surely this is disabling all the same optimisations explicitly? But no - it still crashes.

The 3rd party has been unable to help identify the cause.

Anyone any tips on how I can find which optimisations I can safely use? Who knows - maybe if I can identify the one that actually breaks it, I can get the 3rd party to work around it too?

Cheers

Hi Darren,

I believe you might need to use -optimizations !library/**,!class/**,!field/**,!method/**,!code/** as an equivalent to -dontoptimize.

Instead of disabling an optimizatio nstep for all code, you could also just exclude the 3rd party dependency using -keep rule;
-keep,includecode class com.example.** { *; }

Ideally you could try to narrow down to only target the problematic parts of the 3rd party library instead of using a broad -keep rule as shown above.

Kind regards,
Jonas

1 Like