Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a new Mobile.App (Xamarin.Forms) project, try to compile, but "Failed linking references"

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)

like image 555
Jeremy D Avatar asked Aug 21 '19 13:08

Jeremy D


3 Answers

For whatever reason it can lock itself in this state.

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

like image 172
Jeremy D Avatar answered Oct 29 '22 00:10

Jeremy D


Do this in order:

  1. Delete the bin & obj folders.
  2. Rebuild the solution
like image 24
Ryan Avatar answered Oct 28 '22 22:10

Ryan


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

like image 1
nsimeonov Avatar answered Oct 28 '22 23:10

nsimeonov