1

I am getting a DllNotFoundException while trying to access my shared library from the Unity Android player. I placed the .so file in the Assets->Plugins->Android folder that the article HERE told me to. I ran adb logcat and watched the logs and here is a snippet of the error:

E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
D/dalvikvm(27320): Trying to load lib /data/data/com.pheenixstudios.tankraigearena/lib/libwinsocklib.so 0x419ccfd0
E/Unity   (27320): Unable to find winsocklib
D/dalvikvm(27320): Trying to load lib /data/data/com.pheenixstudios.tankraigearena/lib/libwinsocklib.so 0x419ccfd0
E/Unity   (27320): Unable to find winsocklib
D/dalvikvm(27320): Trying to load lib /data/data/com.pheenixstudios.tankraigearena/lib/libwinsocklib.so 0x419ccfd0
E/Unity   (27320): Unable to find winsocklib
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
E/        (  532): inv_get_mag_rate
I/Unity   (27320): DllNotFoundException: winsocklib
I/Unity   (27320):   at (wrapper managed-to-native) NetworkFunctions:dllInit ()
I/Unity   (27320):   at AndroidNetworkController.Start () [0x00000] in <filename unknown>:0

I extracted the built APK and the winsocklib.so file is in the lib\armeabi-v7a folder. it is correctly spelled. I even tried appending lib to the filename to no avail.

Here is the C# code just for additional context:

[DllImport("winsocklib", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dllInit")]
public static extern Double dllInit();

I also simplified it to:

[DllImport("winsocklib")]
public static extern Double dllInit();

In addition, i made a copy and placed it in Assets->Plugins as well. I also tried renaming both to libwinsocklib without changing the c# code. Still the same exception.

Does anyone have any ideas? Can anyone shed some light on the situation?

Community
  • 1
  • 1
Nicholas Terry
  • 1,812
  • 24
  • 40

1 Answers1

1

Figured out the issue. I was using a lib build with Linux ABIs, not Android ABIs. The lib now works.

Nicholas Terry
  • 1,812
  • 24
  • 40
  • 1
    Hi, I am facing the same issue too. How do we make a lib build with android ABI. I am generating a armeabi library and I get the dllnotfoundexception – Pradeep Vairamani Mar 24 '13 at 15:26
  • you need to use the android NDK [HERE](http://developer.android.com/tools/sdk/ndk/index.html) Make sure its on your path. You will need Android makefiles. For an example, refer to my github project [HERE](https://github.com/nterry/39DLL-4-Linux) specifically the README file [HERE](https://github.com/nterry/39DLL-4-Linux/blob/master/README.md) for complete build instructions for both linux and Android. – Nicholas Terry Apr 17 '13 at 21:43