Idea: APK --> decompile to Smali file --> import into Android Studio for dynamic debugging
1. Use AndroidKiller to decompile it into a Smali file
Click on Project Management, right click on Smali—>Open Method—>Open Path
2. Copy the smali folder from the previous step to other files (here I created a new app-debug folder) and rename it to src
3. Check the package name and MainActivity in AndroidKiller
Remember the package path of the project. If the application node does not enable the debug configuration, you need to add the configuration android:debuggable="true" to debug
4. Import the smali folder to Android Studio
Open the app_debug folder in Android Studio: File—>Open—>D:\AndroidKiller_v1.3.1\app_debug
Five, configure JDK
Select File->Project Structure
6. To use AndroidStudio to dynamically debug smali code, you must first install the ideasmali plug-in
Download address: https://bitbucket.org/JesusFreke/smalidea/downloads/
Open Android Studio --> File --> Settings -->Plugins
Restart the AS for the plugin to take effect.
7. Set the smali file that needs to be debugged
Right click on the pp-debug/src folder -->Make Directory As --->Source Root
Set up the debugger: run-->edit configurations, +-->Remote JVM Debug
8. Open the command line and enter the command
1) adb shell am start -D -n com.zjm.myapplication/com.zjm.myapplication.MainActivity
to dynamically debug the apk. After running this command, the phone screen will enter the debugging interface. Do not click the dialog box that pops up on the phone (do not click Force Close), it is waiting for debug access
2) Check Android Device Monitor and remember the two values in the red box below
The new version of AndroidStudio has eliminated the Android Device Monitor function, we cannot directly open the Android Device Monitor on the AndroidStudio menu
Found a new method, the path of my Android Device Monitor is: open monitor.bat under D:\Android\Sdk\tools
Then turn off Android Device Monitor (it must be turned off here, because it will occupy port 8700 and cause subsequent port forwarding to fail)
3) Turn on forwarding
C:\Users\Administrator>netstat -aon |findstr 8700
TCP 127.0.0.1:8700 0.0.0.0:0 LISTENING 10708
Check to see if any process is occupying the port, and if not, enable port forwarding directly:
C:\Users\Administrator>taskkill /PID 10708 /F
Success: The process with PID 10708 has been terminated.C:\Users\Administrator>
Then enter the following command to enable forwarding (here jdwp is the Online value of the app to be debugged in Android Device Monitor, and tcp is the debug value)
C:\Users\Administrator>adb forward tcp:8700 jdwp:3669
8700C:\Users\Administrator>
Nine, dynamic debugging
break point
Run-->Debug 'myapp-smail' for debugging
android studio has entered debug mode, press F8 to execute the next step, F9 to run the program
addition!
The above methods often have port forwarding problems. The phenomenon is that the TCP port of the android studio debug cannot be bound to the port of the device application, resulting in the failure to start the debug.
Tried changing the port number, restarting and a series of methods have no effect. Finally, I found a simple and effective way to find the process directly by attaching and then attach it, but I could
n’t find the entrance to open the Choose Process window, so I can only open it through the shortcut key:
bind the shortcut key first
Press the shortcut key to find the desired process. (debug mode is successful)
To add, the above is no problem to use the simulator to debug, but when using the real machine to debug, the following error will appear
Warning : debug info can be unavailable
Tried many methods, the last one is effective, the searched methods are summarized as follows:
1. Plug and unplug the phone. (tried, invalid)
2. Restart Android Studio. (tried, invalid)
3. Restart the computer. (Didn't try it, the cost is too high)
4. adb kill-server + adb start-server. (tried, invalid)
5. Forcibly exit the adb process in the monitor (activity monitor). (tried, invalid)
6. In the "Developer Options" of the mobile phone, turn off and then turn on "USB Debugging". (this method works for me)