android - 找不到与给定名称匹配的资源(位于 'theme' ,值为 '@android:style/Theme.my_theme' )。(APT0000)

标签 android xamarin android-theme

我最近安装了全新的 Xamarin Android(版本 5.10.1 build 6)。当我尝试添加主题时,我收到了可怕的“未找到资源...”错误。
这是我尝试添加的第一个主题,所以我不确定问题是否可能是由于我在代码中编写的内容造成的。 然而,在 StackOverflow 和 Xamarin 论坛上搜索时,我发现该问题可能意味着某些 Android 库未安装。

因此,我从最新的和以前的 API 以及 Extras 安装了更多内容,但仍然遇到相同的错误。
该应用程序只是一个针对手机的简单应用程序,因此我没有安装wear或tv库。 我需要使用 Android API 多久?
还有什么我应该安装的不明显的东西吗?

对于这个特定的错误已经有很多答案,但其中许多答案都很模糊,并且没有给出确切的说明,或者引用了我不认识的组件,我想是因为我正在使用 Xamarin .

这是我的主题代码。

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
  <style name="Theme.my_theme" parent="@android:style/Theme.DeviceDefault.Light.DialogWhenLarge">
    <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> <item name="android:textSize">20sp</item>
  </style>
</resources>

这是 list 。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="My_app.My_app">
    <uses-sdk android:minSdkVersion="17" />
    <application android:label="My_app" android:theme="@android:style/Theme.my_theme" android:icon="@drawable/icon"></application>
</manifest>

这里是 Android 管理器,显示已安装的内容。是否有明显未安装的东西?

androidmanager1 androidmanager2 androidmanager3 androidmanager4

最佳答案

表达式@android:style/Theme.my_theme指向android命名空间内名为Theme.my_theme的资源,而不是您的本地应用程序包。

android:theme="@android:style/Theme.myTheme" 更改为 android:theme="@style/Theme.myTheme" 以修复错误。

关于android - 找不到与给定名称匹配的资源(位于 'theme' ,值为 '@android:style/Theme.my_theme' )。(APT0000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35023339/

相关文章:

Android Studio 在 Ubuntu 18.04 LTS 上不断崩溃

android - 多次打开应用程序后字体不可读

android - API 级别低于 21 的状态栏颜色没有改变

android - 文本输入布局 : Different color for hint label when not focused

android - Android 中的自定义主题

android - 旋转图层列表中的项目以显示启动画面

android - Google Maps Geocoding API 使用限制

c# - Xamarin - 动画 StackLayout

android - Xamarin、Android、Firebase : "Defualt FirebaseApp is not initialized error". ..?

ios - 带有自定义 View 的 Xamarin.Forms 弹出对话框