如何使用R8将原始行号保留在堆栈跟踪中? [英] How to keep original line numbers in stack traces with R8?

查看:153
本文介绍了如何使用R8将原始行号保留在堆栈跟踪中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出如何使用R8保留原始行号.

I'm trying to figure out how to keep original line numbers with R8.

使用当前的AndroidStudio开发应用程序并使用R8对其进行混淆,甚至将 mapping.txt 文件上传至Google Play控制台,在某些情况下,用户的堆栈跟踪都是无用的,因为崩溃与真正的未混淆文件中的崩溃不同.

Doing an app with current AndroidStudio and obfuscating it with R8, and even uploading mapping.txt file to Google Play Console, the Stack Traces of the users are useless in some cases, because the lines of the crash are not the same as in the real non obfuscated file.

这是一个示例,我的班级没有3000行,但是在3052行中报告了错误( com.mypackage.activities.ManagerActivity.onCreate(ManagerActivity.java:3052)):

This is a sample, my class doesn't have 3000 lines, but the error is reported in line 3052 ( com.mypackage.activities.ManagerActivity.onCreate (ManagerActivity.java:3052) ):

Caused by: java.lang.NullPointerException: 
  at com.mypackage.activities.ManagerActivity.onCreate (ManagerActivity.java:3052)
  at android.app.Activity.performCreate (Activity.java:7136)
  at android.app.Activity.performCreate (Activity.java:7127)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2990)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3148)
  at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1861)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6819)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:497)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:912)

有没有一种方法可以获取R8和AndroidStudio的错误的实际行号?请记住,此代码已经与mapping.txt文件混淆了

Is there a way to get the real line number of the error with R8 and AndroidStudio? Remember that this code is already deobfuscated with mapping.txt file

推荐答案

为了正确地跟踪混淆的堆栈跟踪,需要在配置文件中包含以下内容

In order for correct retracing of obfuscated stack traces it is required to have the following in the configuration file

 -keepattributes LineNumberTable,SourceFile

请参见 https://developer.android.com/有关Moe信息的studio/build/shrink-code#decode-stack-trace .

这篇关于如何使用R8将原始行号保留在堆栈跟踪中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆