1b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# 2b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# This ProGuard configuration file illustrates how to process Android 3b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# applications. 4b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Usage: 5b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# java -jar proguard.jar @android.pro 6b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# 7b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# If you're using the Android SDK, the Ant release build and Eclipse export 8b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# already take care of the proper settings. You only need to enable ProGuard 9b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# by commenting in the corresponding line in project.properties. You can still 10b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# add project-specific configuration in proguard-project.txt. 11b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# 12b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# This configuration file is for custom, stand-alone builds. 13b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 14b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Specify the input jars, output jars, and library jars. 15b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Note that ProGuard works with Java bytecode (.class), 16b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# before the dex compiler converts it into Dalvik code (.dex). 17b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 18b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-injars bin/classes 19b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-injars libs 20b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-outjars bin/classes-processed.jar 21b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 22b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-libraryjars /usr/local/android-sdk/platforms/android-9/android.jar 23b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang#-libraryjars /usr/local/android-sdk/add-ons/google_apis-7_r01/libs/maps.jar 24b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# ... 25b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 26b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Save the obfuscation mapping to a file, so you can de-obfuscate any stack 27b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# traces later on. 28b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 29b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-printmapping bin/classes-processed.map 30b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 31b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# You can print out the seeds that are matching the keep options below. 32b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 33b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang#-printseeds bin/classes-processed.seeds 34b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 35b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preverification is irrelevant for the dex compiler and the Dalvik VM. 36b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 37b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-dontpreverify 38b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 39b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Reduce the size of the output some more. 40b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 41b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-repackageclasses '' 42b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-allowaccessmodification 43b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 44b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Switch off some optimizations that trip older versions of the Dalvik VM. 45b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 46b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-optimizations !code/simplification/arithmetic 47b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 48b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Keep a fixed source file attribute and all line number tables to get line 49b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# numbers in the stack traces. 50b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# You can comment this out if you're not interested in stack traces. 51b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 52b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-renamesourcefileattribute SourceFile 53b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepattributes SourceFile,LineNumberTable 54b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 55b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# RemoteViews might need annotations. 56b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 57b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepattributes *Annotation* 58b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 59b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all fundamental application classes. 60b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 61b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.app.Activity 62b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.app.Application 63b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.app.Service 64b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.content.BroadcastReceiver 65b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.content.ContentProvider 66b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 67b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all View implementations, their special context constructors, and 68b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# their setters. 69b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 70b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public class * extends android.view.View { 71b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public <init>(android.content.Context); 72b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public <init>(android.content.Context, android.util.AttributeSet); 73b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public <init>(android.content.Context, android.util.AttributeSet, int); 74b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public void set*(...); 75b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 76b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 77b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all classes that have special context constructors, and the 78b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# constructors themselves. 79b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 80b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclasseswithmembers class * { 81b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public <init>(android.content.Context, android.util.AttributeSet); 82b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 83b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 84b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all classes that have special context constructors, and the 85b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# constructors themselves. 86b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 87b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclasseswithmembers class * { 88b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public <init>(android.content.Context, android.util.AttributeSet, int); 89b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 90b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 91b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all possible onClick handlers. 92b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 93b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclassmembers class * extends android.content.Context { 94b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public void *(android.view.View); 95b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public void *(android.view.MenuItem); 96b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 97b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 98b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve the special fields of all Parcelable implementations. 99b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 100b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclassmembers class * implements android.os.Parcelable { 101b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang static android.os.Parcelable$Creator CREATOR; 102b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 103b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 104b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve static fields of inner classes of R classes that might be accessed 105b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# through introspection. 106b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 107b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclassmembers class **.R$* { 108b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public static <fields>; 109b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 110b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 111b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve annotated Javascript interface methods. 112b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 113b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclassmembers class * { 114b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang @android.webkit.JavascriptInterface <methods>; 115b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 116b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 117b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve the required interface from the License Verification Library 118b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# (but don't nag the developer if the library is not used at all). 119b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 120b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keep public interface com.android.vending.licensing.ILicensingService 121b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 122b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-dontnote com.android.vending.licensing.ILicensingService 123b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 124b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# The Android Compatibility library references some classes that may not be 125b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# present in all versions of the API, but we know that's ok. 126b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 127b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-dontwarn android.support.** 128b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 129b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve all native method names and the names of their classes. 130b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 1312270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom-keepclasseswithmembernames,includedescriptorclasses class * { 132b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang native <methods>; 133b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 134b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 135b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Preserve the special static methods that are required in all enumeration 136b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# classes. 137b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 1382270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom-keepclassmembers,allowoptimization enum * { 139b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public static **[] values(); 140b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang public static ** valueOf(java.lang.String); 141b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 142b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 143b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Explicitly preserve all serialization members. The Serializable interface 144b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# is only a marker interface, so it wouldn't save them. 145b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# You can comment this out if your application doesn't use serialization. 146b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# If your code contains serializable classes that have to be backward 147b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# compatible, please refer to the manual. 148b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 149b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang-keepclassmembers class * implements java.io.Serializable { 150b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang static final long serialVersionUID; 151b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang static final java.io.ObjectStreamField[] serialPersistentFields; 152b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang private void writeObject(java.io.ObjectOutputStream); 153b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang private void readObject(java.io.ObjectInputStream); 154b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang java.lang.Object writeReplace(); 155b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang java.lang.Object readResolve(); 156b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang} 157b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 158b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# Your application may contain more items that need to be preserved; 159b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# typically classes that are dynamically created using Class.forName: 160b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 161b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# -keep public class mypackage.MyClass 162b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# -keep public interface mypackage.MyInterface 163b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# -keep public class * implements mypackage.MyInterface 164b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 165b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# If you wish, you can let the optimization step remove Android logging calls. 166b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang 167b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang#-assumenosideeffects class android.util.Log { 168b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static boolean isLoggable(java.lang.String, int); 169b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static int v(...); 170b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static int i(...); 171b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static int w(...); 172b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static int d(...); 173b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang# public static int e(...); 174b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang#} 175