简体   繁体   中英

Android Library Project: Obfuscate and keep resources

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
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !

-printusage unused.txt
-optimizationpasses 2
-printmapping mapping.txt
# -overloadaggressively
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt

-libraryjars ..\libs

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM