Guide based on https://github.com/josephmoresena/NativeAOT-AndroidHelloJniLib
- Download the Android NDK (I used version r26b)
- Under your project root directory, in
./Properties/PublishProfiles
, create a file namedandroid-arm64.pubxml
with the contents as described in this gist. - Run the following shell commands (written in PowerShell, may be ported to bash or similar)
dotnet build --configuration Release
$env:ANDROID_NDK_ROOT='C:\PUT\PATH\TO\NDK\HERE'
$env:PATH="$env:PATH;$env:ANDROID_NDK_ROOT\toolchains\llvm\prebuilt\windows-x86_64\bin"
$env:ObjCopyName="llvm-objcopy.exe"
$sysroot="$env:ANDROID_NDK_ROOT\toolchains\llvm\prebuilt\windows-x86_64\sysroot"
dotnet publish MyProject.csproj -p:PublishProfile=android-arm64 -p:CppCompilerAndLinker=clang -p:SysRoot="$sysroot"