添加Xamarin.Forms.Visual.Material nuget后无法构建XF Android项目 [英] XF Android project does not build after adding Xamarin.Forms.Visual.Material nuget

查看:48
本文介绍了添加Xamarin.Forms.Visual.Material nuget后无法构建XF Android项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Xamarin Forms项目,现在我想通过新的Visual/Material功能对其进行改进.

I have a Xamarin Forms project and now I'd like to improve it with the new Visual / Material features.

在IOS上,它就像是一种魅力.

On IOS, it works like a charm.

在Android上,我遇到一个奇怪的问题:添加Xamarin.Forms.Visual.Material nuget后,我收到奇怪的错误消息,并且我的项目无法构建:

On Android I have strange problems: after adding Xamarin.Forms.Visual.Material nuget I get weird error messages and my project does not build:

\res\values\values.xml(6): error APT0000: Attribute "statusBarBackground" already defined with incompatible format.
\res\values\values.xml(2): error APT0000: Original attribute defined here.
\res\values\values.xml(10): error APT0000: Attribute "layout_anchorGravity" already defined with incompatible format.
\res\values\values.xml(2): error APT0000: Original attribute defined here.
\res\values\values.xml(17): error APT0000: Attribute "layout_insetEdge" already defined with incompatible format.
\res\values\values.xml(2): error APT0000: Original attribute defined here.
\res\values\values.xml(17): error APT0000: Attribute "layout_dodgeInsetEdges" already defined with incompatible format.
\res\values\values.xml(2): error APT0000: Original attribute defined here.
\res\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.MaterialComponents.Light.DarkActionBar'.
\res\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'materialButtonStyle'.
\res\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.Button'.
\res\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.Button.OutlinedButton'.
\res\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.TextInputLayout.FilledBox'.
\res\values\styles.xml(2): error APT0000: No resource found that matches the given name: attr 'boxCollapsedPaddingTop'.

我在Windows上使用Visual Studio 2017 Professional,我不使用任何预发行的nuget.

I use Visual Studio 2017 Professional on Windows, I don't use any prerelease nuget.

Xamarin.Forms版本是3.6.0.293080. 最低Android API级别为21,目标值为28,并使用28进行编译. Xamarin Android支持库版本为28.0.0.1.

Xamarin.Forms version is 3.6.0.293080. Minimum Android API level is 21, target is 28, and compiled with 28. Xamarin Android support libraries version is 28.0.0.1.

我尝试了通常的技巧(删除bin,obj dir,重新启动Visual Studio,在管理模式下运行,删除Xamarin应用数据...),但都没有帮助.

I tried the usual tricks (delete bin, obj dir, restart Visual Studio, run it in admin mode, delete Xamarin app data...) but neither helped.

如果我从schratch创建一个新项目,并且不做任何事情,只需将visual.material nuget添加到Android项目中,就会发生同样的事情.

The same thing happens if I create a new project from schratch, and don't do anything with it, just add visual.material nuget to the Android project.

您有什么建议吗?非常感谢!

Do you have any suggestions? Thanks a lot!

推荐答案

几天前,我遇到了相同的问题,即我首先将TargetFramework设置为Android 8.1,安装了相同的程序包,然后将其更改为Android9并安装了新程序包

I had the same issue a few days ago where I first had TargetFramework set to Android 8.1, installed same packages and later changed it to Android9 and installed a new package.

Xamarin.Forms.Visual.Material要求在Android项目选项中设置Android 9,并且您之前已经为Android 8.1配置并安装了nuget软件包.

The Xamarin.Forms.Visual.Material requires Android 9 to be set in Android project options and you previously had 8.1 configured and installed nuget packages for Android 8.1.

如果您仍然使用旧的 packages.config ,例如我要添加NuGet程序包,请确保您始终在csproj的提示路径中看到相同的monodroid字符串,并且不要将81与90混合使用,并且始终具有 monoandroid90 .

If you still use old packages.config like me to add NuGet packages, make sure you always see same monodroid string in hint path in the csproj and don't mix 81 with 90 and always have monoandroid90.

<Reference Include="Xamarin.Forms.Visual.Material , Version=3.6.0.293080, Culture=neutral, processorArchitecture=MSIL">
     <HintPath>..\..\packages\Xamarin.Forms.Material.3.6.0.293080\lib\monoandroid90\Xamarin.Forms.Material.dll</HintPath>
</Reference>

将TargetFramework更改为9后,打开

After changing TargetFramework to 9, open Package Manager Console and run

Update-Package -Reinstall -IgnoreDependencies

让VS更新packages.config和csproj.

to let VS update the packages.config and csproj.

这篇关于添加Xamarin.Forms.Visual.Material nuget后无法构建XF Android项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆