Reputation: 11
I have a small monogame based application in development. It comprises of three projects - a common core, and then an android and desktop top level wrapper. Thus far this has worked fine, and deployed without issue to both platforms. I now wish to add networking, and I have decided on using ENet-CSharp. My test project works fine on desktop, but if I run it in android I am hit with a DLL not found exception when the code calls enet initialisation.
In the build output bin folder I see a libnet.so file, which is also found in the application's directory on the emulator after code deployment to android device. I understand that these are picked up via MSBuild and are already part of the ENet-CSharp nuget content, as per the .targets file:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win\native\enet.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>enet.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\osx\native\libenet.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>enet.dylib</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\linux\native\libenet.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libenet.so</Link>
<Visible>false</Visible>
</Content>
</ItemGroup>
</Project>
The .so file's final location on device after deployment:
My question then is: how do I make the android app recognise the presence of the "dll"? Is the issue that the underlying native library is missing somehow (ENet-CSharp is a c# wrapper of a c library)? I have a feeling that may be the case. I have followed this guide for building the native files. Because I'm not using unity, I thought I should modify the aforementioned.targets file to reference the .so files built using ndk for the different architectures, see the example below. But confusingly, if I remove the content of the targets file, the libenet library is still deployed!
<Content Include="enetdirectory\ENet-CSharp\Source\Native\libs\x86_64\libenet.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libenet.so</Link>
<Visible>false</Visible>
</Content>
Upvotes: 0
Views: 35