
一、反编译APK
这里反编译的时候要记得带上 -d参数,以便动态调试
apktool d -d demo.apk
二、添加属性
在AndroidManifest.xml的application添加属性:android:debuggable=”true”
三、添加调试语句
在主Activity的OnCreate函数下一行添加:
a=0;// invoke-static {},Landroid/os/Debug;->waitForDebugger()V
四、重新打包
重新打包生成apk并签名(需卸载原来的apk)
apktool b -d out -o 3.apk (或apktool b -d out)
安装后打开apk,发现是空白,这里是进入了调试状态,并不是出现错误
五、打开eclipse
打开eclipse–>新建java project(第一次打开在project中找)–>更改默认路径为 out目录–>选择smali–>finished
六、设置断点
设置断点(可在OnCreate函数或OnClick函数等的下一语句下断点),这里需要首先分析源代码,找出自己想要下断点的地方,快捷键Ctrl+shift+B
七、设置调试端口
设置调试端口(可用DDMS查看端口),run-debug configuration->remote debug application–>可右键新建或者用原来的mainactivity,设置端口号–>点击Apply–>debug
问题分析:如果出现 Failed to connect to remote VM. Connection refused. Connection refused: connect
解决方法:尝试在模拟器中kill 调试apk的进程,然后重新打开,重新打开ddms,然后填写对应端口号,这里的ddms不允许关闭。
本文属于原创,转载请注明来自tasfa.cn 如有问题 请联系root@tasfa.cn
I am actually happy to read this blog posts which contains plenty of helpful data, thanks for providing such statistics.
thanks for your reading,Welcome to read more posts in my blog
I do consider all the ideas you have presented to your post.
They are very convincing and will definitely work. Still, the posts are too short
for beginners. May just you please prolong them a bit
from subsequent time? Thank you for the post.
I think you’d better to read the 《Android reserve for beginner》,you know,my post was organized from simple to complicated.if you had already know the front posts,you will think it is so easy to understand this post.Thanks for your reading!