Android – force Proguard gives each method in a class a unique name?

I'm using Proguard to confuse Android applications. Everything's fine, but I'm trying to backtrack the stack trace from the error report

This is an excerpt from my confusion Code:

    private ez a(x paramx)
  {
    return (ez)this.J.get(paramx);
  }

  private void a(com.b.a.f paramf)
  {
    Iterator localIterator = this.K.iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      em localem = (em)localIterator.next();
      if (localem.a((int)(this.i / this.m - 202.0F), (int)(202.0F + (this.i + this.n) / this.m), (int)(this.j / this.m - 202.0F), (int)(202.0F + (this.j + this.o) / this.m)))
        localem.a(paramf, this.m, this.i, this.j);
    }
  }

  private void a(com.b.a.f paramf, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    Iterator localIterator = this.J.entrySet().iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      ez localez = (ez)((Map.Entry)localIterator.next()).getValue();
      if (localez.a(paramInt1, paramInt2, paramInt3, paramInt4))
        localez.a(paramf, this.k, this.m, this.i, this.j);
    }
  }

You will notice that all three methods above (from the same class) have the same name = 'a'. Of course, this will not cause problems at run time because they have different parameters. But in my confused stack trace:

java.lang.Arrayindexoutofboundsexception: length=0; index=0
at java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:117)
at uk.co.ionage.ionage.co.a(UnkNown Source)
at uk.co.ionage.ionage.co.g(UnkNown Source)
at uk.co.ionage.ionage.n.b(UnkNown Source)
at uk.co.ionage.ionage.n.a(UnkNown Source)
at uk.co.ionage.ionage.co.a(UnkNown Source)
at uk.co.ionage.ionage.co.a(UnkNown Source)
at uk.co.ionage.ionage.Gameplay.a(UnkNown Source)
at uk.co.ionage.ionage.cn.run(UnkNown Source)

This is a problem. I don't know which 'a' method it refers to. When I use retrieve.bat, it lists all the methods named 'a'

This is my proguard.config:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontwarn android.support.**
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

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

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

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

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

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

##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with
#fields. Proguard removes such information by default, so configure it to keep
#all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.gameanalytics.android.** { *; }
##---------------End: proguard configuration for Gson ----------

This is very typical, except that I added a little at the end to help support my use of JSON / gson

Can I add an option to force Proguard to specify a different name for each method?

resolvent:

Stack traces become blurred because line numbers are missing. You can keep them using the following Proguard options:

-renamesourcefileattribute MyApplication
-keepattributes SourceFile,LineNumberTable

See Proguard manual > retrace > usage

See the Proguard manual > examples > producing useful stack traces

Alternatively, you can specify a unique name:

-useuniqueclassmembernames

However, the method name can be overloaded and Proguard will not change it

Note: if project.properties is set correctly, the latest version of Android SDK will automatically apply the default part of the configuration:

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>