Forum Xamarin.Android

any workaround for compiler erroring on res-auto XML layout namespace?

KenYeeKenYee USMember ✭✭

Xamarin compiler in Visual Studio complains that the tools namespace is missing an attribute. The layout xml looks like this:

<?xml version> ="1.0" encoding="utf-8"?>




...

Error msg is:

Error 7 No resource identifier found for attribute 'src' in package

setting the tools namespace to res-auto should let it take anything, but it's griping about the tools:src.
I could take it out since this isn't important, but I've got others in the app namespace that are important.

Anyone know of a workaround?

Answers

  • KenYeeKenYee USMember ✭✭

    Well that was useful :-P
    Here's the relevant layout XML again:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="172dp"
        android:orientation="vertical">
    ...
            <ImageView
                android:id="@+id/RewardsCard"
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:elevation="4dp"
                tools:src="@drawable/ic_launcher" />
    
  • KenYeeKenYee USMember ✭✭

    Another example:

    <?xml version="1.0" enc    oding="utf-8"?>
    <DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/DrawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
    ....
        <NavigationView
            android:id="@+id/NavDrawer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/drawerheader"
            app:menu="@menu/draweritems" />
    </DrawerLayout>
    

    It errors w/
    Error 3 No resource identifier found for attribute 'headerLayout' in package
    Error 4 No resource identifier found for attribute 'menu' in package

    The attributes are needed for it to work, so I really need res-auto to work in this case :-(

  • KenYeeKenYee USMember ✭✭

    On a different note, has anyone gotten NavigationView to work w/ Xamarin?

  • KenYeeKenYee USMember ✭✭

    Found out a possible reason for this. I didn't include the Android Support Design Library.
    What's totally confusing is why there are some android support library components in NuGet but others are in the Xamarin Components store. All of them should be in NuGet. Or they should be in Components. Not some in one place and the rest in another :-P

  • KenYeeKenYee USMember ✭✭

    Hah...yes, it was because I didn't pull in the Android Support Design Library. Got the NavigationView working...

  • AsiyehBHLAsiyehBHL USMember ✭✭

    I have the same problem here...
    coudnt found out what u realy did ?
    should i add android support design library in nuget or xamarin store?

Sign In or Register to comment.