DexPatcher / dexpatcher-tool

Android Dalvik bytecode patcher.
https://dexpatcher.github.io/
GNU General Public License v3.0
428 stars 79 forks source link

Debugging not possible after dex2jar #23

Closed koh-osug closed 6 years ago

koh-osug commented 6 years ago

I'm using DexPatcher for patching an AAR file because the annotations and programming in Java are more convenient. When translating the dexed patch back into a jar with dex2jar file for AAR the AAR cannot be debugged anymore. What I noticed is:

I tried to set translateDebugInfo = true in the Dex2jarTask task, but this does not change the result

Lanchon commented 6 years ago

hi,

using dxp to patch java bytecode is unsupported. you are doing a dx/dxp/dex2jar sequence which includes a dx/dex2jar pseudo-roundtrip which could be the source of your troubles.

first, note that dx/dex2jar roundtrips could introduce bugs, not only debug symbol loss. dex2jar is far from perfect.

having said that, you could exercise your setup but omitting the dxp step. this will probably repro your issue proving that it has nothing to do with dxp. if this is the case, try tweaking dx and dex2jar options so that you get debug symbol roundtrips. once that is working, add dxp to the mix. dxp should let the debug data through, but i haven't tested debugging that much.

please report findings.

an alternative: since you are working with java bytecode, you could use one of many java bytecode patching tools. java has a much more mature tool ecosystem than dalvik.

thanks!

koh-osug commented 6 years ago

Hi,

the bytecode patching tool are not as convenient. As least I have found nothing which allows the Java compile approach, programmatic byte code manipulation with asm is too low level. My first trace is that the line numbers are somehow changed.

Lanchon commented 6 years ago

well, then make the roundtrip work as i said before, because this is not a dxp problem until proven to be. you could try enjarify instead of dex2jar which should work better for code; but not that it wont translate annotations at all. report findings!

Lanchon commented 6 years ago

the major version of the class file is only 50 not 51 anymore.

also, dex2jar is abandon-ware now. try my releases instead: https://github.com/DexPatcher/dex2jar/releases

koh-osug commented 6 years ago

This can be closed. I was able to live with the limitations of removed debugging messages and haven't looked into the tool chain.