I would like to inject code in an android application at runtime. I have tried to use dx tool to generate a dexfile in the sdcard but when i want to instantiate, it fails. A
You can specify your own DEX file with the DexClassLoader class. This is used by a few apps that want "plugin" behavior.
There's nothing on the device that will generate DEX files, however. There is no mechanism for generating code on the fly and making use of it.