Share via


Load .so file in Xamarin.Android

Question

Monday, March 11, 2019 11:14 AM

I am having an issue with an .so.

Normally I create a bindings project with both .jar and .so but this time I only have the .so file and I need to run specific native methods.

I have tried to follow this thread: https://stackoverflow.com/questions/47433520/load-so-file-in-xamarin-android

But I am stuck with a failed library load: I execute JavaSystem.LoadLibrary("...."); and get

Couldn't load .... from loader dalvik.system.PathClassLoader[DexPathList[[zip file "....apk"],nativeLibraryDirectories=[/data/app-lib/....-10, /vendor/lib, /system/lib]]]: findLibrary returned null

And in the specific device, which 100% has the right architecture: Java.Lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/....-1/base.apk"],nativeLibraryDirectories=[/data/app/....-1/lib/arm, /data/app/...-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib]]] couldn't find "...."

I added the .so file in my droid project inside lib/armeabi/.....so and have it setup as AndroidNativeLibrary.

How can I actually load the Library without issues?

All replies (2)

Monday, March 11, 2019 1:23 PM âś…Answered

I was able to solve my problem.

I had to do 2 things,

The name on the load had to be without lib and in the folder had to be with lib.

The folder structure had to be libs/armeabi/libname.so and I also had to add the libs/armeabi-v7a/libname.so


Tuesday, March 12, 2019 9:18 AM

Congrats, and thanks for sharing the solution.