android apk 包调试
转自 http://d-kovalenko.blogspot.com/2012/08/debugging-smali-code-with-apk-tool-and.html
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
Questions are welcome. Have a nice day :)
P.S. If you have problems with breakpoints, this may help.
- 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
- Decode your .apk file to
outdirectory, use-doption:java -jar apktool.jar d -d my.app.apk out
- Add
android:debuggable="true"attribute to<application>section inout/AndroidManifest.xmlfile. - Build
outdirectory to .apk file:java -jar apktool.jar b -d out my.app.to.debug.apk
- Sing and install
my.app.to.debug.apkto the Android device used for debugging - Delete
out/buildfolder - Run NetBeans, click "File" -> "New Project". Choose "Java"->"Java Project with Existing Sources". Click "Next".
- Specify
outas "Project Folder". Click "Next". - Add
out/smalifolder to the "Source Package Folder" list. Click "Next" and then "Finish". - Start
my.app.to.debug.apkon the device, run DDMS, find your application on a list and click it. Note port information in last column - it should be something like86xx / 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". - Debugging session should start: you will see some info in a log and debugging buttons will show up in top panel.
- Set breakpoint. You must select line with some instruction, you can't set breakpoint on lines starting with ".", ":" or "#".
- 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.
Questions are welcome. Have a nice day :)
P.S. If you have problems with breakpoints, this may help.
浙公网安备 33010602011771号