x64
x64

Reputation: 342

JNI GetMethodID called with pending exception java.lang.ClassNotFoundException

I am developing an android library (.aar) which has mainly native code and bit of java code mainly to provide java interface to the application code.

I have a demo app which utilizes the library and everything works fine.

Now I am giving this library someone who is supposed to be an OEM. They are developing a (system) app which utilizes this library. In their case the native library throw exception in the following code.

shapeClass = env->FindClass("xx/yy/zz/Shape");
addMethod = env->GetMethodID(shapeClass, "addPoint", "(FF)V");

This is the error they get

JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception java.lang.ClassNotFoundException: Didn't find class "xx.yy.zz.Shape" on path: DexPathList[[zip file "/system/app/AA/AA.apk"],nativeLibraryDirectories=[/system/app/AA/lib/arm, /system/app/AA/AA.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/lib, /vendor/lib]]

I googled and did not find much on what differs in the system app. How a system app environment is different than a regular app environment?

Please note that above two lines of the code are called from the java wrapper code through JNI interface. So there is no chance that the (Shape) class is not loaded because Shape class and invoking class are in the same library (same .aar file).

Upvotes: 1

Views: 1709

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57173

The system apps must keep their native libraries in /system/lib or /vendor/lib directory. In some cases, the native library may be embedded in the APK file, but then the app manifest must declare

android:extractNativeLibs=”false” 

Upvotes: 2

Related Questions