Native Android .so files that are part of a nuget package are not copied to android simulator when deploying MAUI application

Anonymous
2023-10-31T17:09:01.89+00:00

I am trying to use a .Net Nuget package that contains native Android .so files. However, the Linux versions of the .so files are included in the built Android .apk file and not the Android versions.
When deploying to the Android Simulator, this causes the application to fail.

This is sample code from the Nuget package nuspec file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<package>
  <metadata>
    <id>MyCo.MyLib</id>
    <version>1.0.0.1</version>
    <authors>MyCo Authors</authors>
    <owners>MyCo</owners>
    <license type="file">LICENSE.md</license>
    <projectUrl>https://www.my.com/downloads/nuget</projectUrl>
    <icon>icon.png</icon>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <summary>This package is really, really good</summary>
    <description>This package is really, really good</description>
    <copyright>Copyright (c) 2023 MyCo, Inc. All Rights Reserved.</copyright>
    <dependencies>
      <group targetFramework="uap">
        <dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" />
        <dependency id="Microsoft.NETCore.Platforms" version="1.1.0" />
        <dependency id="NETStandard.Library" version="[2.0.1, )" />
      </group>
      <group targetFramework="netstandard2.0">
        <dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" />
        <dependency id="Microsoft.NETCore.Platforms" version="1.1.0" />
      </group>
      <group targetFramework="monoandroid">
        <dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" />
        <dependency id="Microsoft.NETCore.Platforms" version="1.1.0" />
      </group>
      <group targetFramework="xamarinios">
        <dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" />
        <dependency id="Microsoft.NETCore.Platforms" version="1.1.0" />
      </group>
      <group targetFramework="net6.0">
        <dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
      </group>
    </dependencies>
  </metadata>
  <files>
    <!-- package icon -->
    <file target="icon.png" src="..\icon.png" />
    <!-- license file -->
    <file target="LICENSE.md" src="..\LICENSE.md" />

    <!-- net6.0 -->
    <file target="lib\net6.0" src="\\MyDistBin\Bin\net\MyLibrary.dll" />

    <!-- UWP -->
    <file target="runtimes\win-arm\nativeassets\uap" src="\\MyDistBin\Bin\UWPUnmanaged\arm\MyLibrary.Native.dll" />
    <file target="runtimes\win-x64\nativeassets\uap" src="\\MyDistBin\Bin\UWPUnmanaged\x64\MyLibrary.Native.dll" />
    <file target="runtimes\win-x86\nativeassets\uap" src="\\MyDistBin\Bin\UWPUnmanaged\Win32\MyLibrary.Native.dll" />

    <!-- DotNet Standard -->
    <file target="lib\netstandard2.0" src="\\MyDistBin\Bin\net\MyLibrary.dll" />

    <!-- Native Desktop -->
    <file target="runtimes\win-x64\nativeassets\netcoreapp" src="\\MyDistBin\Bin\CDLL\x64\Final\Release\mynativelib.dll" />
    <file target="runtimes\win-x86\nativeassets\netcoreapp" src="\\MyDistBin\Bin\CDLL\Win32\Final\Release\mynativelib.dll" />
    <file target="runtimes\linux-x64\nativeassets\netcoreapp" src="\\MyDistBin\Bin\Linux\x64\release\libmynativelib.so" />
    <file target="runtimes\osx-x64\nativeassets\netcoreapp\MyLibrary.framework\" src="\\MyDistBin\Bin\AppleNuGet\macOS\Release\MyLibrary.framework\**" />

    <!-- Native Android Xamarin -->
    <file target="lib\MonoAndroid\arm64-v8a" src="\\MyDistBin\Bin\Android\release\arm64-v8a\libmynativelibrary.so" />
    <file target="lib\MonoAndroid\armeabi-v7a" src="\\MyDistBin\Bin\Android\release\armeabi-v7a\libmynativelibrary.so" />
    <file target="lib\MonoAndroid\x86_64" src="\\MyDistBin\Bin\Android\release\x86_64\libmynativelibrary.so" />
    <file target="lib\MonoAndroid\x86" src="\\MyDistBin\Bin\Android\release\x86\libmynativelibrary.so" />

    <!-- Native Android MAUI -->
    <file target="runtimes\android-arm\native" src="\\MyDistBin\Bin\Android\release\armeabi-v7a\libmynativelibrary.so" />
    <file target="runtimes\android-arm64\native" src="\\MyDistBin\Bin\Android\release\arm64-v8a\libmynativelibrary.so" />
    <file target="runtimes\android-x64\native" src="\\MyDistBin\Bin\Android\release\x86_64\libmynativelibrary.so" />
    <file target="runtimes\android-x86\native" src="\\MyDistBin\Bin\Android\release\x86\libmynativelibrary.so" />

    <!-- Native iOS Xamarin-->
    <file target="build\xamarinios\MyLibrary.framework" src="\\MyDistBin\Bin\AppleNuGet\iOS\Release\MyLibrary.framework\**" />

    <!-- Native iOS MAUI -->
    <file target="runtimes\ios\native\MyLibrary.framework" src="\\MyDistBin\Bin\AppleNuGet\iOS\Release\MyLibrary.framework\**" />

    <!-- Native Mac MAUI -->
    <file target="runtimes\maccatalyst-x64\native\MyLibrary.framework\" src="\\MyDistBin\Bin\AppleNuGet\macOS\Release\MyLibrary.framework\**" />

    <file target="build\monoandroid" src="build\monoandroid\MyCo.MyLib.targets" />
    <file target="build\net6.0" src="build\net6.0\MyCo.MyLib.targets" />
    <file target="build\netstandard2.0" src="build\netstandard2.0\MyCo.MyLib.targets" />
    <file target="build\uap" src="build\uap\MyCo.MyLib.targets" />
    <file target="build\xamarinios" src="build\xamarinios\MyCo.MyLib.targets" />
  </files>
</package>
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,396 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,624 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more