Search code examples
xamarinxamarin.androidmvvmcrossxamarin-studio

No resource identifier found for attribute 'MvxBind' in package in Xamarin Android app


I'm using Xamarin Studio v5.10.1 and Xamarin Android v6.0.0.34 and MvvmCross v3.5.1.

I keep getting this error message when I build the solution:

No resource identifier found for attribute 'MvxBind' in package my.package

I've seen all the question in stack overflow regarding this error but nothing helped.

Here is what I tried:

  1. Clean everything and rebuild
  2. Used res-auto instead of my package name
  3. Upgrade to the latest Mono Android

It seems that the file MvxBindingAttributes.xml is not copied to the Resources/Values folder. I assume it is supposed to be extract from Cirrious.MvvmCross.Binding.Droid.dll but somehow it doesn't.

I also tried creating the MvxBindingAttributes.xml file myself in the right place. It fixed the compilation error but a runtime error complaining about the same thing (resource id's not found).


Solution

  • OK. I just checked. It doesn't seem like the NuGet actually installs MvxBindingAttributes.xml into the Resources\values folder. So you have to create it yourself:

    The contents need to be this: 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>
    

    EDIT:

    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.