adelphes / android-dev-ext

Android debugging support for VS Code
https://marketplace.visualstudio.com/items?itemName=adelphes.android-dev-ext
MIT License
216 stars 29 forks source link

[Feature Request] Work with reversed application's source #130

Closed Anon-Exploiter closed 1 year ago

Anon-Exploiter commented 3 years ago

Hi,

Is it possible to make the extension work with source of decompiled applications (apks) using jadx or d2j-dex2jar? I've been trying to make it work with apks I have but it doesn't hit the breakpoints of those.

I guess it has to do something with the path of the application etc. which isn't being satisfied.

Anon-Exploiter commented 3 years ago

To give more details.

This (https://stackoverflow.com/a/58969794) but in VS code utilizing your extension.

Anon-Exploiter commented 3 years ago

The issue arises in the appSrcRoot key's value. It isn't being satisfied with the decompiled code. I've shared the directory structure of an application decompiled with jadx in the screenshot.

image

It would be awesome if we can support it somehow! :)

adelphes commented 3 years ago

If the decompiler produces valid Java code which matches the line numbers encoded in the app debug info, I think this should work. Normally appSrcRoot is set to the root of the package folders, where AndroidManifest.xml normally lives (I don't see it in your source tree - does the decompiler not extract it?). The reason it's reporting No source files found is because it's trying to find folders matching the package names inside a well-known source folder (like 'main' or 'java').

I would suggest:

That should be enough to allow the debugger to find the package-name folders and the java source files. If your decompiler has produced a good Java file, everything should then match up and your breakpoints should be hit.

Anon-Exploiter commented 3 years ago

Thanks, I get your point. In my case, I'm using jadx which keeps AndroidManifest.xml in the resources directory and the Java source inside the sources directory.

I'm not sure if the decompiled code will have the same lines (sequence) as the original order. I think I've been having some issues in Android studio because of this as well since the bytecode doesn't match the Java code (in sequence/line numbers).

adelphes commented 3 years ago

Yes, it's a common problem with decompilers - the line numbers are encoded in the compiled files so the decompiled files should be formatted to match, but many don't bother which makes debugging very difficult.

It looks like there is already an issue about this in jadx: https://github.com/skylot/jadx/issues/476

Anon-Exploiter commented 1 year ago

Closing this one.