Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

How to debug an Xposed module? #138

Closed
lozn00 opened this issue Dec 15, 2016 · 10 comments
Closed

How to debug an Xposed module? #138

lozn00 opened this issue Dec 15, 2016 · 10 comments
Labels

Comments

@lozn00
Copy link

lozn00 commented Dec 15, 2016

Does not support debugging or I operate a little problem? Deubg run found those breakpoints have become invalid icon, I tried to uninstall also try to restart the system is still unable to break

问 是不支持调试还是我操作有点问题? deubg运行 发现那些断点都变成无效的图标了 ,我尝试卸载也尝试重启 系统依然无法断点

@rovo89
Copy link
Owner

rovo89 commented Dec 15, 2016

Sorry, but I don't have any idea what you're talking about. Is this related to Xposed at all?

@lozn00
Copy link
Author

lozn00 commented Dec 15, 2016

Sorry, the question I asked may be too low.
I mean I can only run plugins written, but use Android Studio development tools to debug
The icon set breakpoints will become red cross to break.

nstantRun: Exception while patching foo.bar
java.lang.ClassNotFoundException: Didn't find class "me.veryyoung.qq.luckymoney.HideModule$6" on path: DexPathList[[dex file "dalvik.system.DexFile@4a9c36d4"],nativeLibraryDirectories=[/data/data/**y/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

@aviraxp
Copy link

aviraxp commented Dec 16, 2016

Disable InstantRun please.

@lozn00
Copy link
Author

lozn00 commented Dec 17, 2016

@aviraxp thant you Still can not debug

@lozn00
Copy link
Author

lozn00 commented Dec 17, 2016

@aviraxp

Is there a better development skills I now practice very troublesome, constantly restart each time I modify the code I need to restart the phone to take effect

@rovo89
Copy link
Owner

rovo89 commented Dec 17, 2016

@qssq Are you trying to debug your Xposed module? I think it's somehow possible, but hard to achieve. Also, you indeed need to restart your device after making changes to your module, that cannot be changed.

@lozn00
Copy link
Author

lozn00 commented Dec 17, 2016

@rovo89
Yes , i want trying to debug your Xposed module ,thank you for your answer
So the simulator can be relatively easy to achieve it?like genymotion
Google comes with simulator And China night simulator(夜神模拟器)

@rovo89
Copy link
Owner

rovo89 commented Dec 17, 2016

No, it's very hard to debug an Xposed module. I don't think I've ever done this myself before.
All usual Android debuggers assume that you want to debug an app, which runs in its own process. But Xposed modules are executed in a totally different way, and they share processes with the ROM and apps. Unless you're an expert and have fully understood how Android internals and Xposed work, the answer is "no, it's not possible".

@rovo89 rovo89 closed this as completed Dec 17, 2016
@rovo89 rovo89 changed the title Android studio run my own app why can't breakpoint debugging? How to debug an Xposed module? Dec 17, 2016
@MPeti1
Copy link

MPeti1 commented Mar 29, 2018

I think I've found a solution. It's simple and effective: install [MM-O] Xdebuggable from the Xposed Installer. Enable it, reboot the phone, and after that you can select the app you hooked in the developer settings. After that start the hooked app, go to Android Studio on PC and click Attach debugger. It's the 2nd from the right:

kep

Now a new window will open. Here check "Show all processes" and select the hooked app. If you're done you can place a breakpoint in an XC_MethodHook (or Replacement or what you want) and when the breakpoint is reached, the app will stop executing and you will see the Variables section in the Debug menu filled like when you debug your own app:

kep

I found out this today and I didn't looked it up, but it seems you can't really debug the app while it's starting, because it takes time for you to attach the debugger.
If you want to debug the app from the very beginning of it's lifecycle, you can select "Wait for debugger" in the Developer options. If i remember correctly how it's called with english system language, but it's a switch and it's directly under the menu where you select the app which you want to debug.

I still didn't found out how could you stop at a breakpoint which is directly inside handleLoadPackage or in the main method of the other interfaces (so outside any XC classes), I think you need to attach the debugger to the system server but I have no idea how to do that because you can't find the android process in the list..

@rovo89 Could you put it in the wiki? I think it's useful to know, as you can see in the screenshot yesterday i tried to do the logging of everything but because of nulls it needs to be ugly or error prone, and also hard to modify, and also it's a lot of time to write the logging and a pain to read the detailed logs even if i try to format them with tabs

EDIT: since i failed to install Xdebuggable (package installer said it cant be installed), i used the Advanced Logging module. It's in the repo, but this version is not working, the framework will log it's HackService class can't be found. You can do what i did: clone this project and build the module yourself. If you can't because you don't have disk space (NDK is big) or PC, tell me you need the apk and i will upload it here.

@newdive
Copy link

newdive commented Nov 10, 2018

First you need to be able to debug an android app using these three steps

  1. adb shell am set-debug-app -w --persistent packageName
  2. adb shell monkey -p packageName -c android.intent.category.LAUNCHER 1
  3. in android studio debugger option , click Attach debugger to Android process,
    and choose the target app with packageName

After that ,you can add break point to you XposedModule method, and then trigger method within the target app, and start debugging

note:

  1. in the adb command listed above, you must replace the packageName
    with the actual package name of your target app like 'com.whatsapp.xxx'
  2. if you want to restore debugged app to normal, use adb shell am clear-debug-app

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants