Friday, April 20, 2012

Proguard, Maven and obfuscating multiple layers of libraries


I was trying to obfuscate a project and kept getting errors like this:

[proguard] Warning: library class xxx.Xxx extends or implements program class yyy.YYY
 [proguard] Warning: there were 1 instances of library classes
depending on prog
ram classes.
 [proguard]          You must avoid such dependencies, since the
program classes
 will
 [proguard]          be processed, while the library classes will
remain unchang
ed.
 [proguard] Error: Please correct the above warnings first.

This can happen if you have a dependency to a library X, that transitively depends on library Y, and you try to obfuscate your app + Y, but not X.  There are two ways to solve this.

Solution 1:
Change X to obfuscate and embed Y. When your app is then obfuscated, it will have no idea that X references the classes in Y, as it will reference obfuscated versions.

Solution 2:
Change your app to obfuscate and embed X.  Thus X and Y will be obfuscated together, it will all be considered "app" code by Proguard, and the error will go away.

0 Comments:

Post a Comment

<< Home