I put a .jar file containing .dex file to directory "/sdcard", then I try to load the class in the .jar file using DexClassLoader and PathClassLoader respectively. Both of them can load the class successfully. What are differences between them? Here is my code:
String dexPath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "test.jar";
PathClassLoader classLoader1 = new PathClassLoader(dexPath, getClassLoader());
DexClassLoader classLoader2 = new DexClassLoader(dexPath, getDir("dex", 0).getAbsolutePath(), null, getClassLoader());
try {
Class clazz1 = classLoader1.loadClass("com.focans.loader.Peter");
Class clazz2 = classLoader2.loadClass("com.focans.loader.Peter");
} catch (Exception e) {
e.printStackTrace();
}