7

I have the latest visual studio 2019 (16.2.3) Community Edition installed with Xamarin.

When I create a brand new solution with the Mobile App (Xamarin.Forms) template and pick Android, I can't build it in any configuration.

It ends up with this output:

1>"C:\Users\myuser\source\repos\App3\App3\App3.Android\App3.Android.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
1>(_UpdateAndroidResgen target) -> 
1>  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1697,2): error APT0000: resource style/Theme.AppCompat.Light.Dialog (aka com.companyname.app3:style/Theme.AppCompat.Light.Dialog) not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(4): error APT0000: style attribute 'attr/colorAccent (aka com.companyname.app3:attr/colorAccent)' not found.
1>  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1697,2): error APT0000: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.companyname.app3:style/Theme.AppCompat.Light.DarkActionBar) not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(2): error APT0000: style attribute 'attr/windowNoTitle (aka com.companyname.app3:attr/windowNoTitle)' not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(2): error APT0000: style attribute 'attr/windowActionBar (aka com.companyname.app3:attr/windowActionBar)' not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(2): error APT0000: style attribute 'attr/colorPrimary (aka com.companyname.app3:attr/colorPrimary)' not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(2): error APT0000: style attribute 'attr/colorPrimaryDark (aka com.companyname.app3:attr/colorPrimaryDark)' not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(3): error APT0000: style attribute 'attr/colorAccent (aka com.companyname.app3:attr/colorAccent)' not found.
1>  C:\Users\myuser\source\repos\App3\App3\App3.Android\Resources\values\styles.xml(4): error APT0000: style attribute 'attr/windowActionModeOverlay (aka com.companyname.app3:attr/windowActionModeOverlay)' not found.
1>  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1697,2): error APT0000: failed linking references.

Referenced packages in App3.Android.csproj are as follow:

    <PackageReference Include="Xamarin.Forms" Version="4.1.0.555618" />
    <PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.1" />
    <PackageReference Include="Xamarin.Essentials" Version="1.1.0" />

Minimum Android version is Android 5.0 (API Level 21 - Lollipop)

Target Android version is Android 9.0 (API Level 28 - Pie)

4 Answers 4

16

For whatever reason it can lock itself in this state.

Deleting *\bin & *\obj solves the issue.

3
5

Do this in order:

  1. Delete the bin & obj folders.
  2. Rebuild the solution
1

If deleting the bin and obj folders doesn't solve this for you, there is one more thing you can do.

  1. You may have to run dotnet restore in the project folder. Easiest way to do that is by selecting Tools -> Command Line -> Developer Command Prompt from the VS menu.

  2. Reinstall all NuGet packages. Tools -> NuGet Package Manager -> Package Manager Console, then type Update-Package -Reinstall and hit enter

0

I use Prism to create projects, and occasionally this problem occurs。

I solved it with the following:

nuget add the Xamarin.Android.Support.v7.AppCompat to Anroid project.

clean solution and rebuild

1
  • This fixed missing AppCompat error/issue for my project. Thank you
    – JSB
    Jul 21, 2021 at 4:37

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.