1. Modify APK profile Androidmanifest.xml
Modify the Profile <application> subkey, add the Android:debuggable= "true" property, so that the APK is in an adjustable state, packaged back.
<application android:allowbackup= "true" android:debuggable= "true" android:icon= "@drawable/ic_launcher" Android: Label= "@string/app_name" >
2. Debug boot apk (two ways)
1) Use ADB shell am (unused)
Using the format "adb shell am start-d-N Package name/package name + class name" command, you can start an activity from the console
For the specific use of this command, see ADB shell AM
2) using the phone's own debugging function (simple and convenient)
In the developer options on your phone, select the program you want to debug, and then click the program normally, and a dialog box with the title "Waiting For Debugger" pops up, prompting the user that the application is waiting for Debugger attach
3. Ida add-on app
Start android_server as root in the phone
In the main system, use the ADB forward tcp:23946 tcp:23946 command to go to the originating port data
Once you have completed these two steps, you can use Ida to attach to the application. After the attach is complete, in the Ida->debugger->debugger options, set the event breakpoint, add the library Load/unload breakpoint, so that after the app launches, every load/unload a so , will be broken, at this time, the user can go to set breakpoints, the subsequent debugging
4. Launch the App
After the three steps above, the app is ready to be debugged, and you need to start the app and let it run.
In the main system, use DDMS to view the app's debug port number (typically 8700), and then use the following command:
Jdb-connect com.sun.jdi.socketattach:hostname=localhost,port=8700
At this point, the app debugging state is lifted and starts to run normally.
But you will find that the "Waiting for Debugger" dialog box is missing, but the app is still not running because it is automatically disconnected when Ida is attached. As long as you press F9 in Ida, you can get the app to really run.
Android Dynamic Debug Notes