diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-07 16:10:01 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-06-11 15:04:02 -0700 |
commit | e86ac701205c6fdb0d2ae91e025024aec4f6a9de (patch) | |
tree | 55c5160fa64302f0ddadb71296cf1964c39ebbc9 | |
parent | 0fcf4bee6d93c5a5b1c449d48f0307abe953454d (diff) | |
download | sdk-e86ac701205c6fdb0d2ae91e025024aec4f6a9de.zip sdk-e86ac701205c6fdb0d2ae91e025024aec4f6a9de.tar.gz sdk-e86ac701205c6fdb0d2ae91e025024aec4f6a9de.tar.bz2 |
Include a default proguard config file with optimization
Adds a new proguard-android-optimize.txt file alongside the
default proguard-android.txt file in tools/proguard/ which
project.properties files can point to. The shrinking rules
are the same, but unlike proguard-android.txt, the new config
file leave optimization enabled. This allows users to point
to a tool-managed proguard file rather than forking the
default file in order to edit out the -dontoptimize flag.
Change-Id: I2f0fc8361e3964843a4cafe4f4087a6dee68b5ce
-rw-r--r-- | build/tools.atree | 1 | ||||
-rw-r--r-- | files/proguard-android-optimize.txt | 64 | ||||
-rw-r--r-- | files/proguard-android.txt | 17 | ||||
-rw-r--r-- | sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java | 2 |
4 files changed, 72 insertions, 12 deletions
diff --git a/build/tools.atree b/build/tools.atree index 414f143..afdeb75 100644 --- a/build/tools.atree +++ b/build/tools.atree @@ -66,6 +66,7 @@ bin/lint tools/lint sdk/templates/build.template tools/lib/build.template sdk/files/proguard-project.txt tools/lib/proguard-project.txt sdk/files/proguard-android.txt tools/proguard/proguard-android.txt +sdk/files/proguard-android-optimize.txt tools/proguard/proguard-android-optimize.txt # Ant Build Rules sdk/files/ant tools/ant diff --git a/files/proguard-android-optimize.txt b/files/proguard-android-optimize.txt new file mode 100644 index 0000000..f8f5bcb --- /dev/null +++ b/files/proguard-android-optimize.txt @@ -0,0 +1,64 @@ +# This is a configuration file for ProGuard. +# http://proguard.sourceforge.net/index.html#manual/usage.html + +# Optimizations: If you don't want to optimize, use the +# proguard-android.txt configuration file instead of this one, which +# turns off the optimization flags. Adding optimization introduces +# certain risks, since for example not all optimizations performed by +# ProGuard works on all versions of Dalvik. The following flags turn +# off various optimizations known to have issues, but the list may not +# be complete or up to date. (The "arithmetic" optimization can be +# used if you are only targeting Android 2.0 or later.) Make sure you +# test thoroughly if you go this route. +-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* +-optimizationpasses 5 +-allowaccessmodification +-dontpreverify + +# The remainder of this file is identical to the non-optimized version +# of the Proguard configuration file (except that the other file has +# flags to turn off optimization). + +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-verbose + +-keepattributes *Annotation* +-keep public class com.google.vending.licensing.ILicensingService +-keep public class com.android.vending.licensing.ILicensingService + +# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native +-keepclasseswithmembernames class * { + native <methods>; +} + +# keep setters in Views so that animations can still work. +# see http://proguard.sourceforge.net/manual/examples.html#beans +-keepclassmembers public class * extends android.view.View { + void set*(***); + *** get*(); +} + +# We want to keep methods in Activity that could be used in the XML attribute onClick +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +-keepclassmembers class **.R$* { + public static <fields>; +} + +# The support library contains references to newer platform versions. +# Don't warn about those in case this app is linking against an older +# platform version. We know about them, and they are safe. +-dontwarn android.support.** diff --git a/files/proguard-android.txt b/files/proguard-android.txt index 3cc5c8a..fe73bae 100644 --- a/files/proguard-android.txt +++ b/files/proguard-android.txt @@ -10,18 +10,11 @@ # of these optimizations on its own). -dontoptimize -dontpreverify - -# If you want to enable optimization, you should include the -# following: -# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* -# -optimizationpasses 5 -# -allowaccessmodification -# -# Note that you cannot just include these flags in your own -# configuration file; if you are including this file, optimization -# will be turned off. You'll need to either edit this file, or -# duplicate the contents of this file and remove the include of this -# file from your project's proguard.config path property. +# Note that if you want to enable optimization, you cannot just +# include optimization flags in your own project configuration file; +# instead you will need to point to the +# "proguard-android-optimize.txt" file instead of this one from your +# project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java index a78e1a3..24b9260 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java @@ -168,6 +168,8 @@ public final class SdkConstants { /** global Android proguard config file */ public final static String FN_ANDROID_PROGUARD_FILE = "proguard-android.txt"; //$NON-NLS-1$ + /** global Android proguard config file with optimization enabled */ + public final static String FN_ANDROID_OPT_PROGUARD_FILE = "proguard-android-optimize.txt"; //$NON-NLS-1$ /** default proguard config file with new file extension (for project specific stuff) */ public final static String FN_PROJECT_PROGUARD_FILE = "proguard-project.txt"; //$NON-NLS-1$ |