Error: android:attr/lStar not found After Upgrading NuGet Packages

Nathan Sokalski 4,126 Reputation points
2021-12-03T05:46:35.267+00:00

After updating several Nuget packages, my app started giving the following error:

resource android:attr/lStar not found.

The NuGet packages in my app are just the standard ones, meaning the following:

Xamarin.AndroidX.AppCompat (1.3.1.4)
Xamarin.Essentials (1.7.0)
Xamarin.Google.Android.Material (1.4.0.5)

Do I need to downgrade the packages back to what they were before? Is there some known bug with any of them? Is there something I can do to fix the problem?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
{count} vote

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 71,921 Reputation points Microsoft Vendor
    2021-12-03T06:33:04.47+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful