When building a .NET Android project I'm getting the following exception:

Milan Hribal 5 Reputation points
2023-11-09T09:25:45.4166667+00:00

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: The "VerifyVersionsTask" task failed unexpectedly.

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at System.ThrowHelper.ThrowKeyNotFoundException()

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at System.Collections.Generic.Dictionary`2.get_Item(TKey key)

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at Xamarin.Android.Support.BuildTasks.NugetPackages.GatherProjectJsonVersions(String packageIdPrefix, String projectExtensionsPath, IEnumerable1 excludedPackages, Version monoandroidVersion, Dictionary2 packageVersions, TaskLoggingHelper log)

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at Xamarin.Android.Support.BuildTasks.VerifyVersionsTask.Execute()

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

....nuget\packages\xamarin.android.support.annotations\28.0.0.3\build\monoandroid90\Xamarin.Android.Support.Annotations.targets(20,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Developer technologies .NET Xamarin
{count} vote

1 answer

Sort by: Most helpful
  1. MSCollege3000 190 Reputation points
    2023-12-13T02:54:09.13+00:00

    Check your NuGet packages and remove Xamarin.Android.Support.Compat NuGet package. This package is reported to produce these errors. You probably added it for compatibility with older devices.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.