Home » Android » proguard – Android Library Project: Obfuscate and keep resources

proguard – Android Library Project: Obfuscate and keep resources

Posted by: admin May 14, 2020 Leave a comment


I want to compile with Proguard my Android project with some additional Android Library Projects. In fact, most of code and resources lie in these libraries.

I’ve added line “proguard.config=proguard.cfg” into project.properties of main project, I’ve configured cfg-file (-libraryjars ..\libs). Then – right click, Android Tools -> Export Signed Application Package. ADT compiled project for release but app crashed at the first launch: as I read from log, it was because of wrong resource pointer.

I’ve decompiled project and found out very strange thing: if I declare resource in the library, then resource pointer on it becomes 0.

Problem didn’t disappear when I add line “proguard.config=proguard.cfg” into project.properties of all of my Android Library Project.

Any solutions?

Edit: look at fragment of proguard.cfg:

-optimizationpasses 5
-optimizations !

-printusage unused.txt
-optimizationpasses 2
-printmapping mapping.txt
# -overloadaggressively
-dump class_files.txt
-printseeds seeds.txt

-libraryjars ..\libs
How to&Answers:

Are you sure you have the latest tools? Like Eclipse Indigo, ADT v16.0.1 and proguard 4.7? I also had issues before updating to the latest tools.


How do you include/reference to your Android Library Projects? If I read it correctly, you add them as a jar? If so you really might got some trouble with the resources provided by the library projects.

If I am right, try that:

Use the Project Settings and add your library projects there. Do not use some exported jars for that. The way an Android Library Project works is way different than a normal java library works.