android方法名相同吗,android – Force Proguard给一个类中的每个方法一个唯一的名字?...

我正在使用Proguard来混淆Android应用程序.一切正常,但我正在努力从错误报告中回溯堆栈跟踪.

这是我混淆代码的摘录:

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);

}

}

您会注意到上面的所有3种方法(取自同一类)具有相同的名称=’a’.当然,这在运行时不会导致问题,因为它们具有不同的参数.但是在我混淆的堆栈跟踪中:

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)

这是个问题.我不知道它指的是哪种’a’方法.当我使用retrace.bat时,它会列出名为’a’的所有方法.

这是我的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 ;

}

-keepclasseswithmembers class * {

public (android.content.Context, android.util.AttributeSet);

}

-keepclasseswithmembers class * {

public (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 ----------

这是非常典型的,除了我在最后添加了一点来帮助支持我使用JSON / GSON.

我可以添加一个选项来强制proguard为每个方法指定一个不同的名称吗?

解决方法:

堆栈跟踪变得模糊,因为缺少行号.您可以使用以下ProGuard选项保留它们:

-renamesourcefileattribute MyApplication

-keepattributes SourceFile,LineNumberTable

请参阅ProGuard手册> ReTrace> Usage.

或者,您可以指定唯一的名称:

-useuniqueclassmembernames

然而.方法名称可以重载开始,ProGuard不会改变它.

附注:如果正确设置project.properties,最新版本的Android SDK会自动应用配置的默认部分:

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

标签:android,obfuscation,proguard

来源: https://codeday.me/bug/20190714/1454687.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值