mobile/android/config/proguard.cfg
author Ehsan Akhgari <ehsan@mozilla.com>
Fri, 14 Feb 2014 18:48:05 -0500
changeset 186065 91dea745dd4a442e0fe19115b43a8859acde2a79
parent 173100 56161051f7fcc5ea80027bfca7b6dbe48a1e408c
child 209229 a2b9ea476e59464f554b510ae8389cbca115fad2
permissions -rw-r--r--
Backed out 2 changesets (bug 939276) because of build bustage Backed out changeset 1cedc759f877 (bug 939276) Backed out changeset 61cef3b533ba (bug 939276)

# Dalvik renders preverification unuseful (Would just slightly bloat the file).
-dontpreverify

# Uncomment to have Proguard list dead code detected during the run - useful for cleaning up the codebase.
# -printusage

-dontskipnonpubliclibraryclassmembers
-verbose
-allowaccessmodification

# Preserve all fundamental application classes.
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class * extends org.mozilla.gecko.sync.syncadapter.SyncAdapter
-keep class org.mozilla.gecko.sync.syncadapter.SyncAdapter

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# Preserve enums. (For awful reasons, the runtime accesses them using introspection...)
-keepclassmembers enum * {
     *;
}

#
# Rules from ProGuard's Android example:
# http://proguard.sourceforge.net/manual/examples.html#androidapplication
#

# Switch off some optimizations that trip older versions of the Dalvik VM.

-optimizations !code/simplification/arithmetic

# Keep a fixed source file attribute and all line number tables to get line
# numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# RemoteViews might need annotations.

-keepattributes *Annotation*

# Preserve all View implementations, their special context constructors, and
# their setters.

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

# Preserve all classes that have special context constructors, and the
# constructors themselves.

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

# Preserve the special fields of all Parcelable implementations.

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.

-keepclassmembers class **.R$* {
  public static <fields>;
}

# Preserve the required interface from the License Verification Library
# (but don't nag the developer if the library is not used at all).

-keep public interface com.android.vending.licensing.ILicensingService

-dontnote com.android.vending.licensing.ILicensingService

# The Android Compatibility library references some classes that may not be
# present in all versions of the API, but we know that's ok.

-dontwarn android.support.**

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
    native <methods>;
}

#
# Mozilla-specific rules
#
# Merging classes can generate dex warnings about anonymous inner classes.
-optimizations !class/merging/horizontal
-optimizations !class/merging/vertical

# Keep miscellaneous targets.

# Keep the annotation.
-keep @interface org.mozilla.gecko.mozglue.JNITarget

# Keep classes tagged with the annotation.
-keep @org.mozilla.gecko.mozglue.JNITarget class *

# Keep all members of an annotated class.
-keepclassmembers @org.mozilla.gecko.mozglue.JNITarget class * {
    *;
}

# Keep annotated members of any class.
-keepclassmembers class * {
    @org.mozilla.gecko.mozglue.JNITarget *;
}

# Keep classes which contain at least one annotated element. Split over two directives
# because, according to the developer of ProGuard, "the option -keepclasseswithmembers
# doesn't combine well with the '*' wildcard" (And, indeed, using it causes things to
# be deleted that we want to keep.)
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.JNITarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.JNITarget <fields>;
}

# Keep Robocop targets. TODO: Can omit these from release builds. Also, Bug 916507.

# Same formula as above...
-keep @interface org.mozilla.gecko.mozglue.RobocopTarget
-keep @org.mozilla.gecko.mozglue.RobocopTarget class *
-keepclassmembers class * {
    @org.mozilla.gecko.mozglue.RobocopTarget *;
}
-keepclassmembers @org.mozilla.gecko.mozglue.RobocopTarget class * {
    *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.RobocopTarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.RobocopTarget <fields>;
}

# Keep WebRTC targets.
-keep @interface org.mozilla.gecko.mozglue.WebRTCJNITarget
-keep @org.mozilla.gecko.mozglue.WebRTCJNITarget class *
-keepclassmembers class * {
    @org.mozilla.gecko.mozglue.WebRTCJNITarget *;
}
-keepclassmembers @org.mozilla.gecko.mozglue.WebRTCJNITarget class * {
    *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.WebRTCJNITarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.WebRTCJNITarget <fields>;
}

# Keep generator-targeted entry points.
-keep @interface org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI
-keep @org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI class *
-keepclassmembers class * {
    @org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI <fields>;
}

-keep @interface org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI
-keep @org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI class *
-keepclassmembers @org.mozilla.gecko.mozglue.generatorannotations.WrapEntireClassForJNI class * {
    *;
}

# Disable obfuscation because it makes exception stack traces more difficult to read.
-dontobfuscate

# Suppress warnings about missing descriptor classes.
#-dontnote **,!ch.boye.**,!org.mozilla.gecko.sync.**