如何调试与混淆(使用ProGuard)对Android应用程序?

如何调试与混淆(使用ProGuard)对Android应用程序?

问题描述:

当我得到了这样的事情

ERROR/AndroidRuntime(18677): Caused by: java.lang.NullPointerException
ERROR/AndroidRuntime(18677):     at com.companyname.a.a.a(Unknown Source)

我怎么能知道问题的所在,并调试这个问题? 我只得到了ProGuard的输出映射,不知道的行号。 谢谢你。

How can I know where the problem is and debug this issue? I only got the mapping output from ProGuard and don't know the line number. Thanks.

以下行添加到您的ProGuard的配置。

Add the following lines to your proguard configuration.

-renamesourcefileattribute SourceFile    
-keepattributes SourceFile,LineNumberTable

现在你的堆栈跟踪将包括行号,并使用回扫工具附带的ProGuard(包含在Android SDK),您可以像调试正常。

Now your stack traces will include line numbers, and by using the retrace tool that ships with proguard (included in the Android SDK), you are able to debug like normal.

请注意,即使你没有使用这两个配置选项,追溯仍然可以提供输出有用的信息,你的映射文件,虽然没有完全明确。

Note that even if you didn't use these two configuration options, retrace still can output useful information provided you have the mappings file, albeit not totally unambiguously.

注:与映射文件被ProGuard的配置选项产生的:

Note: the file with the mappings is produced by the proguard configuration option:

 -printmapping outputfile.txt

在随Android SDK的Ant文件,它设置为mapping.txt。

In the ant file shipped with the Android SDK, it is set to mapping.txt.

祝你好运。