1

I'm trying to load a class file from a server and instatiante it using different class loaders, but without success.

I tried DexClassLoader, URLClassLoader and PathClassLoader. Whatever I do, the only thing I get is a ClassNotFoundException from loadClass method.

First thing I do is to download:

  • jar file that contains the class file and the sex file
  • jar file that contains the class file but no sex file
  • the naked class file

And store it to the apps private storage folder. Then I try to load the class with one of the ClassLoader implementations mentioned above causing in:

Error: java.lang.ClassNotFoundException: Didn't find class "FormTestView" on path: DexPathList[[zip file "/data/data/[PACKAGE_NAME]/app_test_folder/test.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Any idea?

Maxim Pontyushenko
  • 2,983
  • 2
  • 25
  • 36
user1155504
  • 71
  • 2
  • 5
  • I am getting the same error with `unable to load class com.android.build.gradle.internal.NdkHandler`. Did you ever resolve your issue? – IgorGanapolsky May 23 '16 at 14:28
  • Are you using the ClassLoader.getSystemClassLoader() static method? Try using the istance method getClassLoader from a Context instance – Simone Aonzo Nov 16 '17 at 15:32

1 Answers1

0

Did you convert your .jar file using dx tool in android-sdks/build-tools?

If you did not try that, use this command:

./dx --dex --output yourJarDexConverted.jar yourJar.jar

The resulting yourJarDexConverted.jar file contains classes.dex which is an encrypted file including all the java classes needed by the application distributed as jar.

Luca
  • 1,588
  • 2
  • 22
  • 26
user1540907
  • 191
  • 2
  • 5