How can I change (add) code in .dex file on Android?

Good time of day!) Write a program-code compiler on Android. Use the library javassist can I add or change code as my dex file like this way:
final ClassPool pool = ClassPool.getDefault();
pool.appendClassPath(new LoaderClassPath(getClass().getClassLoader()));
final CtClass compiledClass = pool.get(targetClass);
final CtMethod method = compiledClass.getDeclaredMethod(targetMethod);
method.insertBefore("{ java.lang.System#out.println(\"doA() is called.\");}");

But for the functionality of the export and import my projects I have to do this with dex files that are saved on the sd card for example.

So here's the question. How can I add the code in .dex file, which is separate from the application?
July 8th 19 at 15:52
0 answer

Find more questions by tags AndroidJava