无源码调试smali
0x01 工具
①Android Studio最新版。(用的1.5)
②apktool尽量使用最新版的。(反编译本人用baksmali-2.1.3.jar)
③smalidea插件。下载地址https://github.com/JesusFreke/smali/wiki/smalidea
0x02 具体步骤
安装smalidea插件,选择File->Settings->Plugins,安装之前下载的smalidea插件。
①Android Studio最新版。(用的1.5)
②apktool尽量使用最新版的。(反编译本人用baksmali-2.1.3.jar)
③smalidea插件。下载地址https://github.com/JesusFreke/smali/wiki/smalidea
0x02 具体步骤
安装smalidea插件,选择File->Settings->Plugins,安装之前下载的smalidea插件。
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220413854-617943589.png)
以调试状态启动app (这一步不是必须的,可以先开启app)
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220534823-469140707.png)
通过ddms查看端口:
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220550854-328753120.png)
如果不用 ddms 可以通过adb shell执行 ps | grep kugou命令查看转发端口:
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220606167-100101085.png)
然后进行端口转发:
adb forward tcp:8700 jdwp:24551 (这个必须要转发)
记住这时候需要将DDMS关掉,不然会出现错误![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220623229-698993770.png)
创建DebugSmali/src目录,使用apktool或者baksmali反编译要调试的apk到DebugSmali/src目录,使用Android Studio导入该目录,如图所示:
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220644167-1801955265.png)
然后选择Create project from existing sources,之后一直选择next。
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220711745-239639306.png)
成功导入工程后右键点击 src 目录,设定
Mark Directory As->Sources Root
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220744510-1233548569.png)
配置远程调试的选项,选择Run-->Edit Configurations:
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220921667-1473804168.png)
增加一个Remote调试的调试选项,端口选择:8700
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220939667-429384959.png)
设置端口号
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616220957526-1101324191.png)
之后选择File-->Project Structure 配置JDK
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616221015338-1600841699.png)
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616221109120-1445199850.png)
下好断点之后Run->Debug,
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616221208776-173578043.png)
稍等几秒,断点触发后就可以单步调试
![](https://images2015.cnblogs.com/blog/282719/201606/282719-20160616221228995-47769053.png)
http://www.cnblogs.com/goodhacker/p/5592313.html