在 Xamarin Android 应用程序包中找不到属性 'MvxBind' 的资源标识符
No resource identifier found for attribute 'MvxBind' in package in Xamarin Android app
我正在使用 Xamarin Studio v5.10.1 和 Xamarin Android v6.0.0.34 和 MvvmCross v3.5.1。
我在构建解决方案时不断收到此错误消息:
No resource identifier found for attribute 'MvxBind' in package my.package
我在堆栈溢出中看到了关于此错误的所有问题,但没有任何帮助。
这是我尝试过的:
- 清理一切并重建
- 使用
res-auto
代替我的包名
- 升级到最新的 Mono Android
似乎文件 MvxBindingAttributes.xml
没有复制到 Resources/Values
文件夹。我认为它应该是从 Cirrious.MvvmCross.Binding.Droid.dll
中提取的,但不知何故它不是。
我还尝试在正确的位置自己创建 MvxBindingAttributes.xml
文件。它修复了编译错误,但运行时错误抱怨同样的事情(未找到资源 ID)。
好的。我刚刚检查过。 NuGet 似乎并未实际将 MvxBindingAttributes.xml 安装到 Resources\values 文件夹中。所以你必须自己创建它:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MvxBinding">
<attr name="MvxBind" format="string"/>
<attr name="MvxLang" format="string"/>
</declare-styleable>
<declare-styleable name="MvxControl">
<attr name="MvxTemplate" format="string"/>
</declare-styleable>
<declare-styleable name="MvxListView">
<attr name="MvxItemTemplate" format="string"/>
<attr name="MvxDropDownItemTemplate" format="string"/>
</declare-styleable>
<declare-styleable name="MvxExpandableListView">
<attr name="MvxGroupItemTemplate" format="string"/>
</declare-styleable>
<item type="id" name="MvxBindingTagUnique"/>
<declare-styleable name="MvxImageView">
<attr name="MvxSource" format="string"/>
</declare-styleable>
</resources>
编辑:
This information is not valid for MvvmCross 4.x where MvxBindingAttributes.xml
is included in the MvvmCross.Binding package. This means, that it is no longer necessary to include this file yourself or through a NuGet into your project.
将 MvxBindingAttributes.xml 添加到解决方案中的 Resources/values 文件夹对我有用。
我也在 axml 文件中使用 xmlns:local="http://schemas.android.com/apk/res-auto"
对我来说,我在 XAML 中的命名空间没有正确定义...
我有:
xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.Resource"
...
local:MvxBind
但我的应用程序的命名空间(在项目属性中)是 AndroidApp1.AndroidApp1(它是一个 PoC :))。
所以当我修复它时 - 一切正常:
xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.AndroidApp1"
...
local:MvxBind
我知道这个问题很老,但是如果您在 Xamarin Studio 6.1.5 版和 MvvmCross 4.4.0 版中遇到此错误,请确保您创建的是 "Blank Android App" 而不是 "Android App" 这确保默认情况下不包含任何不会立即与 MvvmCross 一起玩的包。
就我而言,我在 android 清单中输入了错误的包名称。确保 .axml 文件中的 xmlns:local
属性与包名称匹配。
YOUR-PACKAGE-NAME 此处必须相同...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/YOUR-PACKAGE-NAME"
android:layout_width="match_parent"
android:layout_height="match_parent">
这里
希望对您有所帮助
尝试从“管理 NuGet 程序包”中添加引用,然后从搜索中点击写入 MvvmCross.Bind,然后进行安装。
我知道这是个老话题,但我找到了另一个解决方案。
当您创建新项目时,请记住命名 core: name.Core 和 android app: name.Droid 。它解决了我所有的问题。
我正在使用 Xamarin Studio v5.10.1 和 Xamarin Android v6.0.0.34 和 MvvmCross v3.5.1。
我在构建解决方案时不断收到此错误消息:
No resource identifier found for attribute 'MvxBind' in package my.package
我在堆栈溢出中看到了关于此错误的所有问题,但没有任何帮助。
这是我尝试过的:
- 清理一切并重建
- 使用
res-auto
代替我的包名 - 升级到最新的 Mono Android
似乎文件 MvxBindingAttributes.xml
没有复制到 Resources/Values
文件夹。我认为它应该是从 Cirrious.MvvmCross.Binding.Droid.dll
中提取的,但不知何故它不是。
我还尝试在正确的位置自己创建 MvxBindingAttributes.xml
文件。它修复了编译错误,但运行时错误抱怨同样的事情(未找到资源 ID)。
好的。我刚刚检查过。 NuGet 似乎并未实际将 MvxBindingAttributes.xml 安装到 Resources\values 文件夹中。所以你必须自己创建它:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MvxBinding">
<attr name="MvxBind" format="string"/>
<attr name="MvxLang" format="string"/>
</declare-styleable>
<declare-styleable name="MvxControl">
<attr name="MvxTemplate" format="string"/>
</declare-styleable>
<declare-styleable name="MvxListView">
<attr name="MvxItemTemplate" format="string"/>
<attr name="MvxDropDownItemTemplate" format="string"/>
</declare-styleable>
<declare-styleable name="MvxExpandableListView">
<attr name="MvxGroupItemTemplate" format="string"/>
</declare-styleable>
<item type="id" name="MvxBindingTagUnique"/>
<declare-styleable name="MvxImageView">
<attr name="MvxSource" format="string"/>
</declare-styleable>
</resources>
编辑:
This information is not valid for MvvmCross 4.x where
MvxBindingAttributes.xml
is included in the MvvmCross.Binding package. This means, that it is no longer necessary to include this file yourself or through a NuGet into your project.
将 MvxBindingAttributes.xml 添加到解决方案中的 Resources/values 文件夹对我有用。
我也在 axml 文件中使用 xmlns:local="http://schemas.android.com/apk/res-auto"
对我来说,我在 XAML 中的命名空间没有正确定义...
我有:
xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.Resource"
...
local:MvxBind
但我的应用程序的命名空间(在项目属性中)是 AndroidApp1.AndroidApp1(它是一个 PoC :))。
所以当我修复它时 - 一切正常:
xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.AndroidApp1"
...
local:MvxBind
我知道这个问题很老,但是如果您在 Xamarin Studio 6.1.5 版和 MvvmCross 4.4.0 版中遇到此错误,请确保您创建的是 "Blank Android App" 而不是 "Android App" 这确保默认情况下不包含任何不会立即与 MvvmCross 一起玩的包。
就我而言,我在 android 清单中输入了错误的包名称。确保 .axml 文件中的 xmlns:local
属性与包名称匹配。
YOUR-PACKAGE-NAME 此处必须相同...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/YOUR-PACKAGE-NAME"
android:layout_width="match_parent"
android:layout_height="match_parent">
这里
希望对您有所帮助
尝试从“管理 NuGet 程序包”中添加引用,然后从搜索中点击写入 MvvmCross.Bind,然后进行安装。
我知道这是个老话题,但我找到了另一个解决方案。 当您创建新项目时,请记住命名 core: name.Core 和 android app: name.Droid 。它解决了我所有的问题。