- Run Proguard once on the library .jar file - this can make the library self-contained and prevent package name collisions.
- Run Proguard once on the application that uses the library file.
Step by step:
- Ofuscation of library jar is based on http://proguard.sourceforge.net/index.html#manual/examples.html - A typical library.
- To make the library .jar small, list classes to be kept explicitely instead of -keep public class * {public protected *;}
- -keep public class my.package1.* {*;}
- -keep public class my.package2.* {*;}
- To make the library smaller, remove unused classes and obfuscate the used ones, omit -dontshrink
- To optimize and remove dead code, omit -dontoptimize
- In the case of "Unknown verification type [32] in stack map frame" problems when obfuscating the app, try disabling optimizing rules of the library according to http://proguard.sourceforge.net/index.html#manual/optimizations.html. Examples that can be tried until no more errors:
- -optimizations !class/merging/*, !field/*, !method/*, !code/*
- -optimizations !code/*, !field/*
- -optimizations !field/*
- -optimizations !field/propagation/value
- Finally, repackage classes to your organizations domain (www.package.my):
- -allowaccessmodification
- -repackageclasses 'my.package'