I get the following error in my Android project in Visual Studio Code:
/usr/local/share/dotnet/sdk/8.0.204/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1083: The specified RuntimeIdentifier 'android.21-arm64' is not recognized. See https://aka.ms/netsdk1083 for more information. [/Users/name/Projects/…/ProjAndroid.csproj] /usr/local/share/dotnet/sdk/8.0.204/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1083: The specified RuntimeIdentifier 'android.21-arm' is not recognized. See https://aka.ms/netsdk1083 for more information. [/Users/name/Projects/…/ProjAndroid.csproj] Unable to create dependency graph file for project '/Users/name/Projects/…/ProjAndroid.csproj'. Cannot add package reference.
I have the following code in my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>31.0</SupportedOSPlatformVersion>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<UseMauiEssentials>true</UseMauiEssentials>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
<ApplicationId>com.companyname.ProjAndroid</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
<NoStdLib>false</NoStdLib>
<RuntimeIdentifiers>android.21-arm64;android.21-arm</RuntimeIdentifiers>
</PropertyGroup> ...
I switched from Visual Studio for Mac to Visual Studio Code on macOS and now I always get this error. I don't know if I still need the android.21-arm64;android.21-arm in my .csproj file and I don't remember when it was added to my csproj file. What exactly is android.21-arm64;android.21-arm used for in my Android project? Can I remove it?
I have tried to install the necessary RuntimeIdentifier but it's not working.
dotnet runtime install --runtime android.21-arm64
Could not execute because the specified command or file was not found. Possible reasons for this include: You misspelled a built-in dotnet command. You intended to execute a .NET program, but dotnet-runtime does not exist. You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
In the linked article, it has mentioned:
Use portable RIDs, for example,
linux-<arch>
,linux-musl-<arch>
,osx-<arch>
, andwin-<arch>
, instead of version-specific or distro-specific RIDs, such asubuntu.16.04-<arch>
,osx.10.11-<arch>
, andwin10-<arch>
.
You are still using version-specific RIDs, you need to use portable RIDs:
<RuntimeIdentifiers>android-arm64;android-arm</RuntimeIdentifiers>