admin管理员组

文章数量:1123000

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.

If I understand correctly

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=";>
    <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 figure I can modify the above .targets file to reference the .so files built using ndk for the different architectures, i.e.

        <Content Include="enetdirectory\ENet-CSharp\Source\Native\libs\x86_64\libenet.so">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
          <Link>libenet.so</Link>
          <Visible>false</Visible>
        </Content>

But this also has not made a difference. In fact, if I remove the entry entirely the libenet.so is still deployed

本文标签: How to correctly deploy Enet on android as part of a monogame net applicationStack Overflow