Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/Replace/delete class files in Dex #32

Open
dazzleworth opened this issue Mar 21, 2020 · 1 comment
Open

Add/Replace/delete class files in Dex #32

dazzleworth opened this issue Mar 21, 2020 · 1 comment

Comments

@dazzleworth
Copy link

dazzleworth commented Mar 21, 2020

Is is possible say if I have a class file or jar (without source code) file to replace the classes in the target dex file with my class or group of classes in package in a jar file? Either in the Android Studio Plugin version (the normal way of adding library to project) or standalone version. If the class files are already present as dalvik bytecode in the dex file (determined by same package/class names) they can be automatically replaced or manually deleted in the dex then replaced with the source class/jar before being recompiled/APK'ed for final packaging

@Lanchon
Copy link
Member

Lanchon commented Mar 21, 2020

dexpatcher operates on dex files only (dalvik bytecode). jars are java bytecode. add the jar to your patch project as a dependency. the jar contents will be added to the java bytecode output of the patch project. next the patch is converted to dex (using dx or d8). next the patch is applied.

the patch needs to have "package annotations" requesting to DexRemove the original packages you are replacing (maybe recursively). see the dxp-tool sample/test/doc file for details.

this compile/jar2dex/patch process is automated in the dxp-gradle plugins. see the demos. an alternative workflow (not depending on the android gradle plugin) is exemplified in the "patched-dex" sample.

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

No branches or pull requests

2 participants