androidmsbuildmaui

Android Maui App gives "The RuntimeIdentifier 'android-arm' is invalid" when publishing


In order to get my Maui app to work on existing Android phones, I added the following to my .csproj file:

<RuntimeIdentifiers>android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
  

This is correct according to this page. However, when I attempt to publish my app, I get the following compilation error:

The RuntimeIdentifier ‘android-arm’ is invalid.

This page insists that android-arm is a valid RID. I double-checked the command dotnet workload list and I have both android and maui-android workloads installed.

How do I fix this error and publish my Maui app?


Solution

  • I figured it out. The line in the .csproj needs to look like this:

    <RuntimeIdentifiers Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
    

    I have no idea why this would fix it. I was not attempting to build the iOS release, and even if I was, I don't know why iOS would know about android-x86 but not android-arm, nor why iOS not knowing about something would stop it from being included in the Android release. Welcome to Maui 🤷