GDG Chicago Android

Google Developers Group

Its nice that the Android Engineers added proguard support to the SDK and android tools. However, some items that trip up new android developers were left out of the configuration file. Items such as you want to keep stack traces, remove log statements and print mapping, class, seeds files.

Thus, lets add them to the proguard.cfg file in your SDK.Wait! You can hack the SDK files? Yes, there are certain SDK files you can change to make your job somewhat easier and proguard.cfg is just one of them.

Okay, open up the proguard.cfg(sdk/tools/lib/proguard.cfg) file:

at the beginning of the file add:

-printusage unused.txt
-printmapping mapping.txt
# we need stack traces
-keepattributes SourceFile,LineNumberTable
-verbose
-dump class_files.txt
-printseeds seeds.txt

Now, somewhere in the middle of the file add:

# We need to strip out logging
-assumenosideeffects class android.util.Log {
public static int v(...);
public static int d(...);
public static int w(...);
public static int i(...);
}

If you use a log wrapper class replace full package-name.class-name and change the body to fit your user case. That is it close the file and now because you have modified the SDK progaurd.cfg file you can start using the changes right away as you create projects.

Views: 646

Tags: development, proguard, sdk, tricks

Comment

You need to be a member of GDG Chicago Android to add comments!

Join GDG Chicago Android

© 2014   Created by Uki Dominque Lucas.

Badges  |  Report an Issue  |  Terms of Service