Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve java.lang.UnsupportedOperationException

Tags:

android

Please check the given code.

I am getting issue Caused by:

java.lang.UnsupportedOperationException: Failed to resolve attribute at index 24: TypedValue{t=0x3/d=0x30 "res/color/primary_text_material_light.xml" a=1 r=0x10601ce}

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.AppBarLayout>

<RelativeLayout
    android:id="@+id/main_lays"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="60dp"
    android:padding="16dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/autoCompleteTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/fab_single"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/fab_single"
            android:background="@color/app_gray"
            android:gravity="center_vertical"
            android:hint="Contact name"
            android:padding="5dp"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab_single"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:src="@drawable/usersingle"
            app:backgroundTint="@color/colorPrimary" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="140dp"
        android:layout_alignParentBottom="true">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:theme="@style/TextLabel">

            <EditText
                android:id="@+id/messageEdittxt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:gravity="top|left"
                android:hint="Message"
                android:inputType="textMultiLine" />

        </android.support.design.widget.TextInputLayout>
    </RelativeLayout>

</RelativeLayout>

here is my resource file is given below

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="holo_blue">#FF33B5E5</color>
<color name="pressesd_color">#47348e</color>
<color name="default_color">#FFF</color>



<color name="colorPrimary">#125688</color>
<color name="app_gray">#b3b3b3</color>
<color name="colorPrimaryDark">#125688</color>
<color name="textColorPrimary">#FFFFFF</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#c8e8ff</color>
</resources>

please help me out.

like image 693
Prashant Sharma Avatar asked Nov 08 '22 12:11

Prashant Sharma


1 Answers

There are many causes for this but I think it's safe to say something has gone wrong with your theming if this issue occurs.

For me I was defining a theme: android:theme="@style/myTheme" on a Button, and myTheme foolishly had a parent of parent="TextAppearance.AppCompat.Button" due to a copy paste error. That means it could not find button-y related resources. The fix was to make the parent the standard button theme: parent="@style/Widget.AppCompat.Button".

In the OP, I would guess that android:theme="@style/TextLabel" has a parent that is something unrelated. There really should be some lint warnings around these, styles are crazy complicated.

like image 95
Daniel Wilson Avatar answered Nov 14 '22 21:11

Daniel Wilson