Debugging Smali code with apk-tool and NetBeans works!
来源:互联网 发布:chm打开软件 编辑:程序博客网 时间:2024/05/16 05:32
我稍微修改了一下,正在实验中。
Debugging Smali code with apk-tool and NetBeans works!
Ho-ho-ho, it works now! Here is a (more or less detailed) how-to. To debug Smali code with apk-tool, you need
Apk-tool 1.4.1 and NetBeans 6.8. Use these versions, not the latest ones! Currently, the latest versions of apk-tool and NetBeans do not allow to debug Smali code.
Java, JDK and other stuff installed in your system to make Apk-tool and NetBeans working
The step-by-step instruction:
1)Decode your .apk file to out directory, use -d option:
java -jar apktool.jar d -d my.app.apk out
2)Add android:debuggable="true" attribute to <application> section in out/AndroidManifest.xml file.
3)在启动Activity的Init或者OnCreate方法中加入以下语句:
invoke-static {}, Landroid/os/Debug;->waitForDebugger()V
4)Build out directory to .apk file:
java -jar apktool.jar b -d out my.app.to.debug.apk
5)Sign and install my.app.to.debug.apk to the Android device used for debugging
6)Delete out/build folder
7)Run NetBeans, click "File" -> "New Project". Choose "Java"->"Java Project with Existing Sources". Click "Next".
8)Specify out as "Project Folder". Click "Next".
9)Add out/smali folder to the "Source Package Folder" list. Click "Next" and then "Finish".
10)Start my.app.to.debug.apk on the device, run DDMS, find your application on a list and click it. Note port information in last column - it should be something like 86xx / 8700".
In Netbeans, click "Debug" -> "Attach Debugger" -> select "JPDA" and set "Port" to 8700 (or whatever you saw in previous step). Rest of fields should be ok, click "OK".
11)Debugging session should start: you will see some info in a log and debugging buttons will show up in top panel.
12)Set breakpoint. You must select line with some instruction, you can't set breakpoint on lines starting with ".", ":" or "#".
13)Trigger some action in application. If you run at breakpoint, then thread should stop and you will be able to debug step by step, watch variables, etc.
I copy-pasted steps 9-13 from the original instruction (sorry, English is not my native language... and I'm too lazy to "produce unique content for the blog"??, so just copy-pasted description of last 5 steps :)).
Questions are welcome. Have a nice day :)
P.S. If you have problems with breakpoints, this may help.
- Debugging Smali code with apk-tool and NetBeans works!
- Debugging Managed Code with Windbg
- Managed Code Debugging with WinDbg
- How to get an APK smali code
- Get apk file information with aapt tool
- Driver Debugging with WinDbg and VMWare
- Debugging with tcpdump and other tools
- iPhone Memory Debugging with NSZombie and Instruments
- Debugging with tcpdump and other tools
- Debugging tombstones with ndk-stack and addr2line
- Debugging tombstones with ndk-stack and addr2line
- Debugging with Xdebug and Sublime Text 3
- [置顶] Debugging and Profiling PHP with Xdebug
- Indent tool and K&R code style
- Integrating Seam with Maven, Netbeans and GlassFish
- Debugging C and C++ programs with gdb (and ddd)
- Ollydbg - Sabre-gold, Works with Themida and EXECryptor
- Software Exorcism: A Handbook for Debugging and Optimizing Legacy Code
- Square Coins+ 母函数
- 检测程序是否重复运行
- POI 创建 EXCEL
- platform设备驱动简介
- IP数据包格式详解
- Debugging Smali code with apk-tool and NetBeans works!
- CPU 缓存理解
- 谨慎去获取控件的高和宽,以防带来不必要的性能问题
- C#中的delegate和event
- Perl 簡介(適合對 C 語言有點認識的讀者)
- servlet,filter, listener, interceptor 区别与联系
- coreplot 1.2 中固定x,y轴的位置
- raspberry树莓派NFS搭建
- 【IDE-Visual Studio】启动出错(chenlu-1):参数“basePath”不能是相对路径