daramasala
daramasala

Reputation: 3030

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).

Upvotes: 2

Views: 3279

Answers (7)

Dawid Stefaniak
Dawid Stefaniak

Reputation: 346

I know it is old topic but I found another solution. When you create new project remember to name core: name.Core and android app: name.Droid . It solved all my problems.

Upvotes: 0

Daniel Corzo
Daniel Corzo

Reputation: 1075

In my case, I mistyped the package name in the android manifest. Ensure that your xmlns:local attribute in the .axml file match the package name.

YOUR-PACKAGE-NAME must be the same here...

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

and here

Android Manifest

Hope it helps

Upvotes: 1

Hedego
Hedego

Reputation: 294

Try adding a reference from Manage NuGet Packages and from the search tap write MvvmCross.Bind and then install it.

Upvotes: 0

FlannelViolin
FlannelViolin

Reputation: 1

I know this question is real old but if you are having this error in Xamarin Studio version 6.1.5 and MvvmCross version 4.4.0 make sure you are creating a "Blank Android App" instead of a "Android App" This makes sure that no packages are included by default that will not play with with MvvmCross off the bat.

Upvotes: 0

Cheesebaron
Cheesebaron

Reputation: 24470

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.

Upvotes: 0

James Joyce
James Joyce

Reputation: 1774

For me, my namespace in the XAML wasn't defined correctly...

I had:

xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.Resource"
...
local:MvxBind

But the namespace of my app (in project properties) was AndroidApp1.AndroidApp1 (its a PoC :)).

So when I fixed that - it all worked:

xmlns:local="http://schemas.android.com/apk/res/AndroidApp1.AndroidApp1"
...
local:MvxBind

Upvotes: 1

user2259397
user2259397

Reputation: 41

Adding the MvxBindingAttributes.xml to the Resources/values folder in the solution worked for me.

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

I am also using xmlns:local="http://schemas.android.com/apk/res-auto" in the axml file

Upvotes: 2

Related Questions