APK反编译后添加日志

2023-05-12,,

一、反编译

参考前一篇文章

二、添加寄存器(locals)

因为要添加日志,我们一般需要用一个变量来存储TAG,所以需要增加一个寄存器

如:

 # virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
.locals const/ v3, 0x23 invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String; move-result-object v1

这里的第三行代码就是。

三、添加日志输出代码

在需要添加日志的地方添加代码如下:

const-string v4, "TAG"

invoke-static {v4, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

v4是我们自己定义的TAG变量,v1是需要输出的变量

四、在AndroidManifest.xml文件中打开设试开关

如:

<application android:debuggable="true"

四、编译为debug模式(用debug.keystore签名)

然后就可以在AS中看到日志了。

APK反编译后添加日志的相关教程结束。

《APK反编译后添加日志.doc》

下载本文的Word格式文档,以方便收藏与打印。