Load .so file in Xamarin.Android

Pedro_MonizPedro_Moniz Member ✭✭
edited March 11 in Xamarin.Android

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?

Best Answer

  • Pedro_MonizPedro_Moniz ✭✭
    edited March 11 Accepted Answer

    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

Answers

  • Pedro_MonizPedro_Moniz Member ✭✭
    edited March 11 Accepted Answer

    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

  • jezhjezh Member, Xamarin Team Xamurai

    Congrats, and thanks for sharing the solution.

Sign In or Register to comment.