Hello,
Welcome to our Microsoft Q&A platform!
Do you set the target framework to the Android 11? And your Xamarin.AndroidX.Core >=1.7.0.1, You will get this error, From Google's bug database - we can see that this is by design and that that Androidx 1.7 requires API 31. But Now, API 30 is the latest API version in Approved list of Android SDK and tools. If you set the target framework is API 30, please convert your Xamarin.AndroidX.Core to 1.6, and other dependenices nuget package(Xamarin.AndroidX.Core) need to convert back to previous version.
please check if you install Xamarin.AndroidX.AppCompat
to the 1.3.1.4
, Xamarin.Google.Android.Material
to the 1.4.0.5
, Both of these nuget packages depend on the Xamarin.AndroidX.Core >=1.7.0.1
.
And Xamarin.AndroidX.Browser 1.3.0.9
Xamarin.AndroidX.Legacy.Support.V4 1.0.0.11
Xamarin.AndroidX.RecyclerView 1.2.1.4
depend on Xamarin.AndroidX.Core >=1.7.0.1 as well.
Here is my installed nuget package version(Note, if you convert previous version, please clean and rebuild your project). My test project could running normally.
Xamarin.AndroidX.AppCompat 1.3.1.3
Xamarin.AndroidX.Browser 1.3.0.8
Xamarin.AndroidX.Core 1.6.0.3
Xamarin.AndroidX.Legacy.Support.V4 1.0.0.10
Xamarin.AndroidX.Lifecycle.LiveData 2.4.0.1
Xamarin.AndroidX.RecyclerView 1.2.1.3
Xamarin.Essentials 1.7.0
Xamarin.Google.Android.Material 1.4.0.4
If you want to use the 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.