gpt4 book ai didi

android - 添加 Xamarin.Forms.Visual.Material nuget 后,XF Android 项目无法构建

转载 作者:太空狗 更新时间:2023-10-29 15:37:34 27 4
gpt4 key购买 nike

我有一个 Xamarin Forms 项目,现在我想用新的视觉/ Material 功能改进它。

在 IOS 上,它就像一个魅力。

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

\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。

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

我尝试了常用的技巧(删除 bin、obj 目录、重新启动 Visual Studio、在管理员模式下运行它、删除 Xamarin 应用程序数据...)但都没有帮助。

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

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

最佳答案

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

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

如果你仍然使用旧的packages.config像我一样添加 NuGet 包,确保你总是在 csproj 的提示路径中看到相同的 monodroid 字符串,不要将 81 与 90 混合使用,并且始终使用 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后,打开Package Manager Console并运行

Update-Package -Reinstall -IgnoreDependencies

让 VS 更新 packages.config 和 csproj。

关于android - 添加 Xamarin.Forms.Visual.Material nuget 后,XF Android 项目无法构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55523996/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com