Adding .so to Xamarin android binding library

南楼画角 提交于 2021-02-10 05:37:11

问题


I have a xamarin android project (VS2015) which I added a Android bindings library project to to use a java lib. The wrapper works fine and I can call the classes/methods in my application project. However one of the java classes depends on

armeabi/libjnisgfplib.so

I have tried adding to both /Assets and /libs within my application. BuildAction = AndroidNativeLibrary, Copy = Always. Yet it can't find the lib and I keep getting.

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.company-1/base.apk"],nativeLibraryDirectories=[/data/app/com.company-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjnisgfplib.so"

I have tried Java.Lang.JavaSystem.LoadLibrary("libjnisgfplib");before calling the class but I receive the same exeption.

How can I add libjnisgfplib.so to my project so the binding library jar can find it?


回答1:


So it's a total mastery to me why this worked but changing the name from

libjnisgfplib.so to jnisgfplib.so

worked. I am assuming something about it being lib/libjnis was throwing it off, but lib/jnis is fine.




回答2:


Have you tried defining your .so file as an AndroidNativeLibrary using armeabi?

<ItemGroup>
    <AndroidNativeLibrary Include="path/to/libjnisgfplib.so">
        <Abi>armeabi</Abi>
    </AndroidNativeLibrary>
</ItemGroup>

http://developer.xamarin.com/guides/android/advanced_topics/using_native_libraries/




回答3:


Try using libs\armeabi-v7a\libjnisgfplib.so. It solved the same problem I was having.



来源:https://stackoverflow.com/questions/31146327/adding-so-to-xamarin-android-binding-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!