4

I'm trying to implement a hot-fix mechanism in my android app. After googling for a while, here's what I've done:

  1. I generated a dynamic.jar file with the classes that I want to patch. (I'm using eclipse and ADT)
  2. Using dx --dex --output=patch.jar dynamic.jar, I managed to create a jar file that contains classes.dex
  3. In my android code, I loaded the class with DexClassLoader: new DexClassLoader(patchFile.getAbsolutePath(), outputFolder.getAbsolutePath(), null, getClassLoader().getParent() (Notice I'm using getParent())
  4. I've verified that the .dex file is extracted successfully in outputFolder
  5. I changed the class loader to my custom class loader via reflection. And I've verified the custom class loader is working
  6. When I try to load class with CUSTOM_LOADER.loadClass(className) I got ClassNotFoundException

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.

Void Main
  • 2,241
  • 3
  • 27
  • 36
  • It is absolutely necessary to make hotfixes? Anyway, which class can it not load -- one of yours? You didn't post the details of the exception. Have you verified that the end result path is correct? It may be possible that the JRE doesn't want to load classes from outside your JAR file. – Keilaron Mar 12 '15 at 19:03

0 Answers0