I'm trying to implement a hot-fix mechanism in my android app. After googling for a while, here's what I've done:
- I generated a
dynamic.jar
file with the classes that I want to patch. (I'm using eclipse and ADT) - Using
dx --dex --output=patch.jar dynamic.jar
, I managed to create a jar file that containsclasses.dex
- In my android code, I loaded the class with DexClassLoader:
new DexClassLoader(patchFile.getAbsolutePath(), outputFolder.getAbsolutePath(), null, getClassLoader().getParent()
(Notice I'm using getParent()) - I've verified that the
.dex
file is extracted successfully inoutputFolder
- I changed the class loader to my custom class loader via reflection. And I've verified the custom class loader is working
- When I try to load class with
CUSTOM_LOADER.loadClass(className)
I gotClassNotFoundException
So I'm wondering what is wrong? I used DexFile
to list all classes in that .dex
file and the new class is there. Is it even possible to download a subset of compiled classes from Internet?
Thanks in advance.