Recently, I have been studying dynamic debugging technology. There are many tutorials on the Internet about dynamic debugging App based on Smali. Many details have not been posted, and many detours have been taken

Github:https://github.com/hi-dhl/DebugApkSmali

The preparatory work

  • On a Root Android phone, open developer mode
  • Xposed running environment
  • To install the Smalidea plugin, click here to download
  • Install BDOpener. Apk or xdebug.apk

Decompiling Apk (apktool)

Click here to download the latest Apktool and configure the environment.

Download the Apk file you need to decompile and execute

Apktool d Decompiles the Apk nameCopy the code

If you decompile multiple smali folders, you can use Ant to write a script that merges the folders into one

smalidea

If you want to debug smali code, you need to install the third-party plugin: Smalidea

Android Studio–>Preferences–>Plugins–>Install plugin from desk , install the plug-in

Android Studio imports SmALI

  • Delete automatically created resources and code files from an Android project in Xinjiang (ps: Attach debuger to Android Process)

  • Copy the decompiled smali file into the Java folder of the new Android project

PS: You can also use the project “ApkSampleSmali” that I configured. You need to install the Sample. Apk provided for testing

Android Studio dynamically debugs the configuration

Create a debug configuration, [Run–>Edit Configurations–> + –>Remote], name optional, port 8700

Dynamic debugging

  • Enter a breakpoint in the SMali code, marked 1 in the figure below

  • Then click “Attach debuger to Android Process”, mark 2 below

  • Select the process you want to debug, manually enter the corresponding function, that is, enter the breakpoint dynamic debugging (PS: if you want the process is not displayed, please re-check the Xposed Module (BDOpener), restart the phone)

Operating Environment information

  • Xposed Version90-beta3
  • BDOpener 1.0
  • AndoridStudio 3.3.2 rainfall distribution on 10-12
  • Smalidea 0.0.5
  • Apktool 2.4.0

conclusion

Dedicated to sharing a series of Android system source code, reverse analysis, algorithm, translation, Jetpack source code related articles, if you like this article welcome Star to study together, looking forward to growing with you

The article lists

Android 10 source code series

  • How is APK generated
  • APK installation process
  • 0xA03 Android 10 source code analysis: APK loading process of resource loading
  • Android 10 source code: APK
  • Dialog loading and drawing process and use in Kotlin, DataBinding
  • WindowManager View binding and architecture

Android Apps

  • How to get video screenshots efficiently
  • How to package Kotlin + Android Databinding in your project
  • [Google engineers] just released a new Fragment feature, “New ways to transfer Data between Fragments” and source code analysis
  • [2.4K Start] Drop Dagger to Koin
  • [5K +] Kotlin’s performance optimization stuff
  • How does FragmentFactory elegantly use Koin and source code analysis
  • Decrypt RxJava’s exception handling mechanism

Tool series

  • Shortcuts to AndroidStudio that few people know
  • Shortcuts to AndroidStudio that few people know
  • All you need to know about ADB commands
  • 10 minutes introduction to Shell scripting

The reverse series

  • Dynamically debug APP based on Smali file Android Studio
  • The Android Device Monitor tool cannot be found in Android Studio 3.2