Our game is progressing nicely and we are planning on starting closed beta phase soon. So it was time to get ProGuard’s optimize and obfuscate features working. So far they had been disabled.
Optimizing seemed to go through just fine but dexing the end result failed with:
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION: [INFO] com.android.dx.cf.code.SimException: local variable type mismatch: attempt to set or access a value of type java.lang.Object using a local variable of type long. This is symptomatic of .class transformation tools that ignore local variable information.
So I knew I needed to limit the optimizations, but what exactly I didn’t know. Most of the exceptions referred to different Scala classes like
[INFO] ...at bytecode offset 00000022 [INFO] locals: Lscala/collection/IndexedSeqOptimized; [INFO] locals: Lscala/collection/Iterable; [INFO] locals: I [INFO] locals: Lscala/collection/IndexedSeq; [INFO] locals: Lscala/collection/mutable/Builder;
and one exception from AndEngine’s classes.
I finally got my solution by combining the typical optimization flags for Android with something I found from the simple-build-tool wiki. Resulting string to add to your proguard.cfg is:
That did it for me, so I thought I’d share it.