Hello,
Welcome to our Microsoft Q&A platform!
This error comes from Google's androidx.core 1.7
verson. This is by design and that that Androidx 1.7 requires API 31.
You will notice both of them( Xamarin.AndroidX.AppCompat (1.3.1.4)
and Xamarin.Google.Android.Material (1.4.0.5)
) are dependent on the Xamarin.AndroidX.Core(>=1.7.0.1)
, if you see dependencies from nuget package management.
I test it with following version, my project is running normally. So please convert back your nuget package version like following.
Xamarin.AndroidX.AppCompat (1.3.1.3)
Xamarin.Essentials (1.7.0)
Xamarin.Google.Android.Material (1.4.0.4)
===============
Update===============
If you want to use latest nuget package.
I make a test with API 31
Firstly I update VS 2019 to the Version 16.11.7.
Then Open the Android SDKs and tools, change the Approved list to Full List(not supported)(Click the gear in the bottom right corner, select the Repository
) in Android SDKs and tools. You can see the Android S and Sv2 (API 31), install all of them.
When you rebuild it, You may get the following error. If you met the following error, please Install JDK-11 and Configure Visual Studio to use JDK-11,
Error Java SDK 11.0 or above is required when using $(TargetFrameworkVersion) v12.0. Note: the Android Designer is incompatible with Java SDK 11.0: https://aka.ms/vs2019-and-jdk-11 App155
In the end, change the Compile using Android version (Target Framework) to Android 12.0 (S)
And set target Android version to the Android 12.0. Rebuild your project. this error will disappear.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.