找不到属性' MvxBind'的资源标识符。在Xamarin Android应用程序包中

时间:2016-01-15 22:58:41

标签: xamarin xamarin.android mvvmcross xamarin-studio

我使用的是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

我已经看到有关此错误的堆栈溢出中的所有问题,但没有任何帮助。

以下是我的尝试:

  1. 清理所有内容并重建
  2. 使用res-auto代替我的包名称
  3. 升级到最新的Mono Android
  4. 似乎文件MvxBindingAttributes.xml未复制到Resources/Values文件夹。我认为它应该是从Cirrious.MvvmCross.Binding.Droid.dll中提取但不知何故它没有。

    我也尝试在正确的位置自己创建MvxBindingAttributes.xml文件。它修复了编译错误,但是运行时错误抱怨同样的事情(资源ID未找到)。

7 个答案:

答案 0 :(得分:2)

将MvxBindingAttributes.xml添加到解决方案的Resources / values文件夹中,对我有用。

https://github.com/MvvmCross/MvvmCross/blob/3.5/Cirrious/Cirrious.MvvmCross.Binding.Droid/Resources/values/MvxBindingAttributes.xml

我也在axml文件中使用xmlns:local =“http://schemas.android.com/apk/res-auto”

答案 1 :(得分:2)

在我的情况下,我在android清单中输错了包名。确保 .axml 文件中的xmlns:local属性与包名称匹配。

您的包裹名称必须与此相同...

<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">

在这里

Android Manifest

希望有所帮助

答案 2 :(得分:1)

对我来说,我在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

答案 3 :(得分:0)

行。我刚刚检查过看起来NuGet实际上并没有将MvxBindingAttributes.xml安装到Resources \ values文件夹中。所以你必须自己创建它:

内容必须是:https://github.com/MvvmCross/MvvmCross/blob/3.5/Cirrious/Cirrious.MvvmCross.Binding.Droid/Resources/values/MvxBindingAttributes.xml

<?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>

修改

  

此信息对MvvmCross 4.x 有效,其中MvxBindingAttributes.xml包含在 MvvmCross.Binding 包。这意味着,不再需要自己或通过NuGet将此文件包含到项目中。

答案 4 :(得分:0)

我知道这个问题真的很老但是如果您在Xamarin Studio版本6.1.5和MvvmCross版本4.4.0中遇到此错误,请确保您正在创建一个&#34;空白Android应用程序&#34;而不是&#34; Android应用程序&#34;这样可以确保默认情况下不包含任何不能与MvvmCross一起使用的包。

答案 5 :(得分:0)

尝试从Manage NuGet Packages添加引用,然后从搜索点击中写入MvvmCross.Bind,然后安装它。

答案 6 :(得分:0)

我知道这是一个老话题,但我找到了另一个解决方案。 当你创建新项目时记得命名core:name.Core和android app:name.Droid。它解决了我所有的问题。