ProGuard - Obfuscate and Shrink a Packages only?

android, obfuscation, proguard

Solution

You can preserve all classes except the ones in some packages with an option like

-keep class !somepackage1.**,!somepackage2.** { *; }

The exclamation marks mean "not these classes", thus only matching all remaining classes. The asterisk between parentheses means "all fields and methods".

A setting like this one really constrains ProGuard's optimization and obfuscation though. The fewer -keep constraints, the better the results.

Problem

Each time i tried using ProGuard i either have faced problems generating apk or the generated apk has issues regarding internet connectivity etc. So i want to know if i could just Obfuscate and Shrink Specific Packages with out using any other functionality.

Original source