DexPatcher / dexpatcher-tool

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

Patching Java .jar files and Android .aar files #15

Open continuemycoding opened 6 years ago

continuemycoding commented 6 years ago

patch-lib in dexpatcher-gradle-samples is not only patch library, I need patch only jar library sometimes.

Lanchon commented 6 years ago

hi, i don't understand.

1) what exactly do you want to patch? an APK or something else? 2) what do you want as output?

thanks

continuemycoding commented 6 years ago

Sorry for my poor english.I want to patch a jar library to output a jar library.

continuemycoding commented 6 years ago

I can do it using smali, but it is hard. I want to modify Android Jar files at source-level using Java. @Lanchon thanks

Lanchon commented 6 years ago

what is an Android Jar file? are you talking about an "Android library" with an ".aar" extension?

continuemycoding commented 6 years ago

I have made a mistake with JAR (Java ARchive), I want to patch a jar file to output a jar file or patch a aar file to output a aar file.

continuemycoding commented 6 years ago

I want to patch some android jar file no source code, modify some code logic, use it for my app development.

Lanchon commented 6 years ago

Contents of different file types and what DexPatcher can patch

DexPatcher patches Dalvik/Android bytecode, not Java bytecode, so it only works with dex and apk files.

to patch jar or aar files you need to use solutions made for Java bytecode, of which are many.

continuemycoding commented 6 years ago

Java bytecode can be converted to Dalvik/Android bytecode by dex2jar tools.so I hope you can upgrade DexPatcher support patch jar to output jar.

Lanchon commented 6 years ago

dxp does not patch java bytecode and never will.

How to patch a .jar file

if you trust dex2jar (sometimes it works fine... depends), then you can:

example: the dexpatcher-tool test build system and shell script.

How to patch an .aar file

inside the aar file there is a classes.jar file. extract it and patch it as per the above steps. if you need to patch the aar resources, go ahead and edit them manually; resources in aar files are not compiled.