Learn to look at the snow article: http://bbs.pediy.com/showthread.php?t=189610, is to study notes, tidy up, in case you forget to blog to check.
1. First use Apktool to decompile the apk file
Apktool d-d xxxxx.apk (-D must be added, otherwise you cannot set breakpoints in Eclipse, you cannot debug )
2. In the output folder, open the Androidmanifest.xml with the text Editing tool to search for the following keywords
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
Locate the Activity node that contains the above information, record the value of its Android:name property, the main class it applies to, and modify it to the package name. Main class, and add Debug properties
Android:debuggable= "true"
After modification
3. Insert the debug wait Smali code in the OnCreate method of the main activity
a=0;// invoke-static {}, Landroid/os/debug;->waitfordebugger () V
4. Use Apktool to recompile apk, sign, install to the phone to run
I was in the compile time again error, use this method can solve: http://www.cnblogs.com/dacainiao/p/5036774.html
Run on Phone:
At this point you will see the program to stay in the white screen interface, then do not move the device and quit the program, because the program is now running to just add the Waitfordebugger code here, this line of code means to hang up, wait for the debugger.
Here's how to set up an environment for real-Time debugging:
5. Start Eclipse, build a Java project
1) Java project, Project, File---New
2) Project name randomly, use the default location option removed, location Select the folder that was just recompiled, and next
3) Select the Smali folder and finish
6. Find the OnCreate method for the main activity in Eclipse and add a breakpoint after Waitfordebugger
If your eclipse does not appear above (a=0;//...), it means that you did not add-D to the time of the anti-compilation, you cannot set the breakpoint
7. Open Ddms, if you run the modified program in step 4th, a program that can be debugged (port: 8614) is displayed in the list of devices in Ddms. (If XXX is occupied, you can first eclipse shut down, open Ddms and then open Eclipse)
8. Now all you have to do is associate the code with the debugger. Back to eclipse, configuring remote debugging
1) Debug configurations, menu run, debug
2) Double-click the remote Java application,host default localhost on the line, Port fill the 7th step to get 8614, and then apply, Debug.
9. Eclipse automatically switches to the debug view and sees that the program has run and breaks the executable code on the next line, and the related variables can be viewed directly.
Eclipse Dynamic Debug Smali