如何在 Android 上使用混淆(使用 ProGuard)的应用程序进行调试?

发布于 2024-09-27 01:49:30 字数 250 浏览 5 评论 0原文

当我遇到这样的问题时,

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

我怎样才能知道问题出在哪里并调试这个问题? 我只得到 ProGuard 的映射输出,不知道行号。 谢谢。

When I got something like this

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

自此以后,行同陌路 2024-10-04 01:49:30

将以下行添加到您的 proguard 配置中。

-renamesourcefileattribute SourceFile    
-keepattributes SourceFile,LineNumberTable

现在,您的堆栈跟踪将包括行号,并且通过使用 proguard 附带的 retrace 工具(包含在 Android SDK 中),您可以像平常一样进行调试。

请注意,即使您没有使用这两个配置选项,只要您有映射文件,retrace 仍然可以输出有用的信息,尽管并不完全明确。

注意:带有映射的文件是由 proguard 配置选项生成的:

 -printmapping outputfile.txt

在 Android SDK 附带的 ant 文件中,它被设置为 mapping.txt。

祝你好运。

Add the following lines to your proguard configuration.

-renamesourcefileattribute SourceFile    
-keepattributes SourceFile,LineNumberTable

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.

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

 -printmapping outputfile.txt

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

Good luck.

べ繥欢鉨o。 2024-10-04 01:49:30

要利用 Android Market 帐户中的任何堆栈跟踪,您可以使用通过 ProGuard 配置中的 -printmapping 选项生成的映射文件,以及 ReTrace(ProGuard 配套工具)来解码堆栈跟踪。您也可以使用地图文件的内容手动解码,但这很乏味。

在 ProGuard 手册的示例下,有一节介绍了生成有用的模糊堆栈跟踪,包括如何保留行号。

不幸的是,如果您没有设置 ProGuard 来保留行号,那么您将只能识别抛出异常的方法。

To make use of any stack traces from your Android Market account, you can use your map file, produced with the-printmapping option in the ProGuard config, with ReTrace (ProGuard companion tool) to decode the stack trace. You can also decode by hand using the contents of the map file, but this is tedious.

In the ProGuard Manual under examples, there is a section about producing useful obfuscated stack traces including how to keep line numbers.

Unfortunately if you did not set the ProGuard to keep the line numbers, then you will only be able to identify the method that throws the exception.

无悔心 2024-10-04 01:49:30

要回溯混淆的 ProGuard 文件,请执行以下步骤:

  1. 您需要安装 Proguard。

  2. Proguard 为您提供了一个 UI 模式,这是一个很棒的回溯工具。

  3. 打开MAC机中找到的proguardgui.sh

    /Users/{name}/Library/Android/sdk/tools/proguard/bin/proguardgui.sh
    

    您可以通过终端运行它。

proguardgui

  1. 然后,您可以输入映射文件和要回溯的片段,并且应该回溯

proguardgui 输出

To retrace back obfuscated ProGuard file do the following steps:

  1. You need to install Proguard.

  2. Proguard provides you with a UI mode which is great tool to retrace.

  3. Open up the proguardgui.sh which you find it in MAC machine

    /Users/{name}/Library/Android/sdk/tools/proguard/bin/proguardgui.sh
    

    You can run it through the terminal.

proguardgui

  1. You can then enter your mapping file and the snipped you want to retrace and it should be retraced

proguardgui outputs

近箐 2024-10-04 01:49:30

将堆栈跟踪粘贴到 stack_trace.txt 中

运行以下命令: java -jar retrace.jar classes-processed.map stack_trace.txt

retrace.jar 位于 sdk\tools\proguard\lib\retrace.jar
classes-processed.map 是混淆时由 proguard 生成的输出文件

Paste your stack trace in stack_trace.txt

Run the following command: java -jar retrace.jar classes-processed.map stack_trace.txt

retrace.jar is at sdk\tools\proguard\lib\retrace.jar
classes-processed.map is the output file generated by proguard when you did obfuscation

绳情 2024-10-04 01:49:30

以下是 Android SDK 中有关 retrace 工具的官方文档的链接:https ://developer.android.com/studio/build/shrink-code#decode-stack-trace

这篇文章也很好:https://medium.com/@maheshwar.ligade/de-obfuscate-stack-traces-6e19a52a3379

对于所有复制粘贴的兄弟:

retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]

Here's a link to official documentation on retrace tool from Android SDK: https://developer.android.com/studio/build/shrink-code#decode-stack-trace

This article is good too: https://medium.com/@maheshwar.ligade/de-obfuscate-stack-traces-6e19a52a3379

For all you copy-paste bros:

retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文