Search code examples
javaandroidandroid-ndkjava-native-interfaceunsatisfiedlinkerror

Using ndk to create and the load a library but having problems with the load


I'm currently trying to do the hello-jni sample in android studio and I have encountered an issue.

In the static constructor the System.loadLibrary doesn't work. This is understandable as I currently haven't added the lib path to java.library.path. So I decided to replace it with System.load and using the absolute path and now I get the following error:

java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1093]: Library 'C:/Users/Public/Documents/AndroidStudioProjects/hello-jni/app/src/main/libs/armeabi/libhello-jni.so' not found

I'm a pretty stumped now and would greatly appreciate a push in the right direction.


Solution

  • So the issue I had was to do with the CPU of my emulator. I ended up using an emulator with an ARM cpu instead of an Intel Atom (x86) and it worked. Although this solves the immediate problem I am confused about why this is an issue in the first place. I have the .so file in the x86 libs folder. Any reasoning to why it doesn't work would be greatly appreciated.