Search code examples
androidadtproguardacra

bug after obfuscating android app with ACRA


After obfuscating with proguard using ADT I have the following error when executing the app:

05-20 19:59:20.158: E/AndroidRuntime(14515): FATAL EXCEPTION: main 
05-20 19:59:20.158: E/AndroidRuntime(14515): java.lang.NoSuchFieldError: PUT

It seems to be due to missing acra libraries. The progaurd-project.txt is:

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify

-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.**


# AWS:
-keep class org.apache.commons.logging.**               { *; }
-keep class com.fasterxml.jackson.**                    { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler  { *; }
-keep class com.amazonaws.javax.xml.transform.sax.*     { public *; }
-keep class com.amazonaws.javax.xml.stream.**           { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class org.codehaus.**                             { *; }
-keep class com.amazonaws.**                            { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler  { *; }
-keep class com.amazonaws.internal.**                   { *; }
-keep class com.amazon.**                               { *; }
-keepattributes Signature,*Annotation*

# Otherwise return Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
-dontwarn com.fasterxml.jackson.databind.**
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**
-dontwarn com.amazonaws.services.securitytoken.**
-dontwarn com.fasterxml.jackson.databind.**
-dontwarn org.apache.http.annotation.**
-dontwarn org.ietf.jgss.**
-dontwarn org.w3c.dom.bootstrap.**
-dontwarn com.amazonaws.**

-libraryjars /home/alejo/Documentos/Android/adt-bundle-linux-x86_64-20140321/sdk/platforms/android-19/android.jar

How could I exclude the obfuscation off all external libraries?, to prevent these type of errors.


Solution

  • I don't know of a way to prevent obfuscation of all external libs, but hopefully this doc will get you past your ACRA-specific issues.

    In general, most Android 3rdparty libs will include a section in their documentation about how to configure Proguard to play nice with the lib.