1

我正在使用 dexguard 来混淆我的应用程序,但是当我这样做时,我在运行应用程序时会崩溃。下面是堆栈跟踪。

04-08 17:46:11.786: E/AndroidRuntime(7569): java.lang.RuntimeException: An error occured while executing doInBackground()
04-08 17:46:11.786: E/AndroidRuntime(7569):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.lang.Thread.run(Thread.java:841)
04-08 17:46:11.786: E/AndroidRuntime(7569): Caused by: java.lang.NoSuchFieldError: ˈ
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.lang.Class.getDeclaredAnnotation(Native Method)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.lang.Class.getAnnotation(Class.java:243)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at o.hS.ˊ(:124)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at o.ȑ.ˊ(:113)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at o.ڋ.doInBackground(:42)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-08 17:46:11.786: E/AndroidRuntime(7569):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-08 17:46:11.786: E/AndroidRuntime(7569):     ... 4 more

这是我从 ACRA lib init 方法中得到的,因为我们有 getAnnotation 方法。我用过-keepattributes *Annotation*并且-keep class org.acra.ACRA {*;}

但没有任何运气...

有人知道吗?

谢谢,
吉姆。

4

1 回答 1

2

您可能不需要混淆 ACRA 代码,因为它不是秘密库。因此,您可以执行以下操作:

# Keep all the ACRA classes
-keep class org.acra.** { *; }

或者,如果您非常特别,您可以尝试使用https://github.com/ACRA/acra/wiki/Proguard配置 ACRA,方法是在配置文件中包含以下内容:

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
    *;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
    *;
}

-keepnames class org.acra.sender.HttpSender$** {
    *;
}

-keepnames class org.acra.ReportField {
    *;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
    public void addCustomData(java.lang.String,java.lang.String);
    public void putCustomData(java.lang.String,java.lang.String);
    public void removeCustomData(java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
    public void handleSilentException(java.lang.Throwable);
}    
于 2015-05-07T16:20:21.253 回答