APK反编译后添加日志

一、反编译

参考前一篇文章

二、添加寄存器(locals)

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

如:

1 # virtual methods
2 .method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
3     .locals 4
4 
5     const/16 v3, 0x23
6 
7     invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
8 
9     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中看到日志了。

posted @ 2017-02-13 18:08  观海云不远  阅读(839)  评论(0编辑  收藏  举报