DllNotFoundException on Android

前端 未结 1 1486
孤独总比滥情好
孤独总比滥情好 2021-01-22 01:45

I\'m trying to load shared libraries in Unity. It works on Windows/Editor but not on Android, whatever I do or use for libraries I always get the DllNotFoundException.

I

相关标签:
1条回答
  • 2021-01-22 02:33

    I noticed few things you are doing wrong:

    my lib.so files are in the Asset/Plugins/libs/armeabis-v7a/ folder.

    That should be at:

    Assets/Plugins/Android/libs/armeabi-v7a

    If you have the x86 architecture version of the plugin,you should place them at:

    Assets/Plugins/Android/libs/x86
    

    I tried different syntax for DllImport (assuming the lib is called Plugin, and the files Plugin.dll and libPlugin.so) :

    None of those are correct. If the plugin file name is "libPlugin.so", you should use "Plugin" as the name.

    • Do not include the lib prefix.
    • Do not include the ".so" postfix.

    Again, if the plugin name is "libVideoPlayer.so", you have to use "VideoPlayer". The "lib" and ".so" are removed. Nothing else will work.

    One final note for you, for Android C++ plugin, you do not need to export the plugin. For example, DLLExport __declspec(dllexport) is not necessary.

    Although, you must put the function name inside "extern "C""

    0 讨论(0)
提交回复
热议问题