我正在使用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=0at 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 <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 ----------
这是非常典型的,除了我在最后添加了一点来帮助支持我使用JsON / GSON.
我可以添加一个选项来强制proguard为每个方法指定一个不同的名称吗?
解决方法:
堆栈跟踪变得模糊,因为缺少行号.您可以使用以下ProGuard选项保留它们:
-renamesourcefileattribute MyApplication-keepattributes Sourcefile,lineNumbertable
请参阅ProGuard手册> ReTrace> Usage.
请参阅ProGuard手册>例子> Producing useful stack traces
或者,您可以指定唯一的名称:
-useuniqueclassmembernames
然而.方法名称可以重载开始,ProGuard不会改变它.
附注:如果正确设置project.propertIEs,最新版本的AndroID SDK会自动应用配置的默认部分:
proguard.config=${sdk.dir}/tools/proguard/proguard-androID.txt:proguard-project.txt
总结 以上是内存溢出为你收集整理的android – Force Proguard给一个类中的每个方法一个唯一的名字?全部内容,希望文章能够帮你解决android – Force Proguard给一个类中的每个方法一个唯一的名字?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)