Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:error: '' is incompatible with attribute android:background (attr) reference|color

Tags:

android

I can't run my app and some of the attributes are unrecognized, resources aren't supported as the app build results suggest.How do i fix all of the resource values? Can it be a problem from the dependencies? can the android studio read the dependecies and resource allocation.How is it related to incompatablity issues of the android resources Here is my xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="16dp"
        android:background="@color/colorPrimary"
        />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/toolBar"
    android:id="@+id/add_reminder_layout_top"
    android:orientation="vertical"
    >
    <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/reminder_title"
        android:layout_marginLeft="32dp"
        android:layout_marginTop="10dp"
        android:hint="Name"
        android:textSize="20sp"
        android:minLines="1"
        android:background="@android:color/transparent"
        android:drawableLeft="@drawable/ic_person_black_24dp"
        android:drawablePadding="12dp"
        android:gravity="center|start"
        android:textColor="@android:color/background_dark"
        android:scrollHorizontally="false"
        android:textColorHint="@android:color/background_dark"
        android:inputType="textCapWords"
        android:layout_marginRight="16dp"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/phone_no"
        android:layout_marginLeft="32dp"
        android:hint="phone Number"
        android:layout_marginTop="15dp"
        android:layout_marginBottom="10dp"
        android:textSize="20sp"
        android:background="@android:color/transparent"
        android:drawableLeft="@drawable/ic_phone_black_24dp"
        android:drawablePadding="12dp"
        android:gravity="center|start"
        android:textColor="@android:color/background_dark"
        android:scrollHorizontally="false"
        android:textColorHint="@android:color/background_dark"
        android:inputType="phone"
        android:layout_marginRight="16dp"
        />
</LinearLayout>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/add_reminder_layout_top">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:layout_marginTop="8dp"
            android:text="@string/details"
            android:id="@+id/details"
            android:textSize="15sp"
            android:gravity="center_vertical"
            android:layout_marginLeft="72dp"
            android:textColor="@android:color/primary_text_light"/>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:clickable="true"
            android:onClick="setDate"
            android:id="@+id/date"
            android:background="@drawable/ic_launcher_foreground"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/date_icon"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="32dp"
                android:src="@drawable/ic_date"
                android:layout_centerVertical="true"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/date_icon">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/date_text"
                    android:textSize="15dp"
                    android:text="@string/date"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/set_date"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:clickable="true"
            android:onClick="setTime"
            android:id="@+id/time"
            android:background="?android:attr/selectableItemBackground"> 


            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/time_icon"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="32dp"
                android:src="@drawable/ic_time"
                android:layout_centerVertical="true"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/time_icon">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/time_text"
                    android:textSize="15dp"
                    android:text="@string/time"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/set_time"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:id="@+id/repeat">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/repeat_icon"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="32dp"
                android:src="@drawable/ic_repeat"
                android:layout_centerVertical="true"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:id="@+id/repeat_ll"
                android:layout_toRightOf="@+id/repeat_icon">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/repeat_text"
                    android:textSize="15dp"
                    android:text="@string/repeat"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/set_repeat"
                    android:textSize="15dp"
                    />
            </LinearLayout>
            <Switch
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/repeat_switch"
                android:layout_centerVertical="true"
                android:layout_alignParentRight="true"
                android:layout_marginRight="16dp"
                android:layout_marginLeft="8dp"
                android:onClick="onSwitchRepeat"
                android:checked="true"
                android:textOn="On"
                android:textOff="Off"/>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:clickable="true"
            android:onClick="setRepeatNo"
            android:id="@+id/repeat_no"
            android:background=""
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/repeat_no_icon"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="32dp"
                android:src="@drawable/ic_repeat_no"
                android:layout_centerVertical="true"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/repeat_no_icon">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/repeat_no_text"
                    android:textSize="15dp"
                    android:text="@string/repetition_interval"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/set_repeat_no"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="72dp"
            android:clickable="true"
            android:onClick="selectRepeatType"
            android:id="@+id/repeat_type"
            android:background="@mipmap/ic_launcher"
            >
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/repeat_type_icon"
                android:layout_alignParentLeft="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="32dp"
                android:src="@drawable/ic_repeat_no"
                android:layout_centerVertical="true"/>
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_toRightOf="@+id/repeat_type_icon">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/repeat_type_text"
                    android:textSize="15dp"
                    android:text="@string/type_of_repetitions"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/set_repeat_type"
                    android:textSize="15dp"
                    />

            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</ScrollView>

<com.getbase.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/starred1"
    android:clickable="true"
    android:onClick="selectFab1"
    fab:fab_icon="@drawable/notification_off"
    fab:fab_colorNormal="@color/colorAccent"
    fab:fab_colorPressed="@color/colorPrimary"
    app:fab_size="mini"
    android:layout_alignParentRight="true"
    android:layout_marginTop="170dp"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="5dp"/>
<com.getbase.floatingactionbutton.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/starred2"
    android:clickable="true"
    android:onClick="selectFab2"
    fab:fab_icon="@drawable/notification_on"
    fab:fab_colorNormal="@color/colorAccent"
    fab:fab_colorPressed="@color/colorPrimary"
    app:fab_size="mini"
    android:layout_alignParentRight="true"
    android:layout_marginTop="170dp"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="5dp"/>

<CheckBox
    android:id="@+id/checkBox_completed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/add_reminder_layout_top"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="11dp"
    android:layout_marginLeft="48dp"
    android:layout_marginStart="48dp"
    android:text="Completed" />

<CheckBox
    android:id="@+id/checkBox_failed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/checkBox_completed"
    android:layout_alignBottom="@+id/checkBox_completed"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_marginEnd="37dp"
    android:layout_marginRight="37dp"
    android:text="Failed" />

>

And here is my error

Information:Gradle tasks [:app:generateReleaseSources, :app:mockableAndroidJar]
C:\Users\ghjsk\AndroidStudioProjects\NavDrawer\app\src\main\res\layout\activity_add_reminder.xml
Error:error: '' is incompatible with attribute android:background (attr) reference|color.
Error:'' is incompatible with attribute android:background (attr) reference|color.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt
Information:BUILD FAILED in 18s
Information:7 errors
Information:0 warnings
Information:See complete output in console
like image 984
tinsae cherinet Avatar asked Jun 23 '18 13:06

tinsae cherinet


2 Answers

You've got android:background="" in your RelativeLayout with id @+id/repeat_no. Removing that or setting a proper value should fix the issue.

like image 200
Capricorn Avatar answered Oct 23 '22 15:10

Capricorn


API level 28(Androidx) throws exception on android:background="" Correct way to write is android:background="@null"

like image 44
Waqas K Avatar answered Oct 23 '22 15:10

Waqas K