我拥有随Xamarin安装的最新Visual Studio 2019(16.2.3
)社区版。
当我使用Mobile App (Xamarin.Forms)
模板创建全新的解决方案并选择Android时,我无法在任何配置中进行构建。
它最终显示为:
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.
App3.Android.csproj中引用的软件包如下:
<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" />
最低Android版本为Android 5.0 (API Level 21 - Lollipop)
目标Android版本为Android 9.0 (API Level 28 - Pie)
答案 0 :(得分:6)
无论出于何种原因,它都可以将自己锁定在这种状态。
删除*\bin
和*\obj
可解决此问题。
答案 1 :(得分:0)
依次执行以下操作:
答案 2 :(得分:0)
如果删除Expression
和bin
文件夹不能为您解决此问题,那么您还可以做另一件事。
您可能必须在项目文件夹中运行obj
。最简单的方法是从VS菜单中选择“工具”->“命令行”->“开发人员命令提示符”。
重新安装所有NuGet软件包。工具-> NuGet程序包管理器->程序包管理器控制台,然后键入dotnet restore
并按Enter
答案 3 :(得分:-1)
我使用Prism创建项目,有时会出现此问题。
我用以下方法解决了它:
nuget将 Xamarin.Android.Support.v7.AppCompat 添加到Anroid项目。
清洁溶液并重建