- Java, JDK and other stuff installed in your system to make Apk-tool and NetBeans working
- Decode your .apk file to
java -jar apktool.jar d -d my.app.apk out
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
- Run NetBeans, click "File" -> "New Project". Choose "Java"->"Java Project with Existing Sources". Click "Next".
outas "Project Folder". Click "Next".
out/smalifolder to the "Source Package Folder" list. Click "Next" and then "Finish".
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 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".
- 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.