In my application, I'm using DexClassLoader
to load a class of an external apk as follow:
DexClassLoader dexClassLoader = new DexClassLoader("path/to/someApkfile.apk", myOptimizedDirectory, null, myContext.getClassLoader());
Class<?> MyClass = dexClassLoader.loadClass("its.package.name.MyClass");
Then invoking a method using reflection as follow:
Object myInstance = MyClass.newInstance();
MyClass.getDeclaredMethod("foo").invoke(myInstance);
here is the method foo
:
public void foo() {
System.Load("path/to/arch/specific/native/lib/libname.so");
// I know that this native library loaded successfully because JNI_OnLoad is called.
// here is the problem
int result = myNativeMethod("arg");
}
And here the myNativeMethod
:
private native int myNativeMethod(String arg);
Here is the log message:
mMessages: uncaught exception
java.lang.UnsatisfiedLinkError: No implementation found for int its.package.name.MyClass.myNativeMethod(java.lang.String) (tried Java_its_package_name_MyClass_myNativeMethod) ...
I am sure that the method signature in my native code is correct and nothing is wrong there.
Also, I'm sure that it successfully loaded native library, so why does it say No implementation found
?
Any help would be appreciated.