我正在使用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 <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
附注:如果正确设置project.properties,最新版本的Android SDK会自动应用配置的默认部分:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。