Search code examples
androidobfuscationdeobfuscation

Developer Console Error Reports and using ProGuard's "retrace"


I'm signing and releasing apps with a default Eclipse installation. I haven't messed with the default.properties file or the proguard.cfg file, but when I view a stack trace on the Developer Console, the line numbers are still off. So it seems like my code is still getting slightly obfuscated. I read the ProGuard docs, and I tried looking for the mapping.txt file that's supposed to be in /proguard, but found no such folder in there or the bin.

What is going on here? Is there any way to stop it from auto-obfuscating, or at least let me have a mappings.txt file? I'd appreciate any insight. Here's the contents of my default.properties file:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-7

And here is my proguard.cfg file that was automatically generated:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-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.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

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

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

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

Solution

  • In default.properties, you need the line

    proguard.config=proguard.cfg
    

    to enable Proguard.

    From ProGuard docs:

    To enable ProGuard so that it runs as part of an Ant or Eclipse build, set the proguard.config property in the /default.properties file. The path can be an absolute path or a path relative to the project's root.