gpt4 book ai didi

android - Xamarin.Android:错误 APT0000:检索项目父项时出错:找不到与给定名称 '@android:style/Theme.AppCompat' 匹配的资源

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:01:14 26 4
gpt4 key购买 nike

我正在尝试在我的 Xamarin.Android 应用中使用 CoordinatorLayout。我一直在使用以 Theme.Material.Light 作为其父级的自定义主题,在我添加 CoordinatorLayout 之前它运行良好。当我添加它时,我收到一条错误消息,告诉我必须使用 Theme.AppCompat 主题,但是一旦我这样做,应用程序就无法构建并出现以下错误:

/{project directory}/Resources/values/Styles.xml(0,0):
Error APT0000: Error retrieving parent for item:
No resource found that matches the given name
'@android:style/Theme.AppCompat'. (APT0000) (TnpApp.Android)

This answer 建议安装与我正在使用的 Android SDK 匹配的支持库的主要版本。我试过这个(我想我做的一切都是正确的),但它没有帮助。

有没有人有什么想法?

我在 Mac 上使用 Xamarin Studio。

更新 1

我在干净的 Xamarin.Android 项目的 MainActivity.cs 中尝试了以下代码,但构建失败并出现相同的错误。

namespace ThemeTest
{
[Activity(Label = "ThemeTest", MainLauncher = true, Icon = "@mipmap/icon", Theme = "@android:style/Theme.AppCompat.Light")]
public class MainActivity : Activity
{
// ...
}
}

更新 2

我从 /user/.local/share/Xamarin 中删除了除 Mono for Androidzips 之外的所有文件夹,如 this answer 中所建议.我关闭 Xamarin Studio 并重新打开它。我尝试部署该应用程序,Xamarin 重新安装了所有包,但构建失败并出现原始错误。

最佳答案

我可以通过简单地从我的 Styles.xml 中 style 元素的 parent 标签中删除 @android:style/ 来解决这个问题文件。所以看起来像这样......

<style name="MyCustomTheme" parent="@android:style/Theme.AppCompat">

现在看起来像这样......

<style name="MyCustomTheme" parent="Theme.AppCompat">

令我震惊的是,解决方案如此简单,但它确实有效。 :) 我从 this code 得到了这个想法.

关于android - Xamarin.Android:错误 APT0000:检索项目父项时出错:找不到与给定名称 '@android:style/Theme.AppCompat' 匹配的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41642492/

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