0
votes

I tried to use DataBinding Library in my app then i found this error

Android resource compilation failed Output: /Users/adham/Desktop/android/ToDo/app/build/intermediates/incremental/m ergeDebugResources/stripped.dir/layout/activity_main.xml:13: error: duplicate attribute.

Command: /Users/adham/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/563a6f08d33eace272a78ff5e80c3e9b/aapt2-3.2.1-4818971-osx/aapt2 compile --legacy \ -o \ /Users/adham/Desktop/android/ToDo/app/build/intermediates/res/merged/debug \ /Users/adham/Desktop/android/ToDo/app/build/intermediates/incremental/mergeDebugResources/stripped.dir/layout/activity_main.xml Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #2 And this is main_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/layout">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/background"
        android:gravity="center"
        android:orientation="vertical"
        tools:context=".MainActivity">

        <FrameLayout
            android:id="@+id/activity_main_fragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical">

            <ListView
                android:id="@+id/activity_main_list_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_marginBottom="8dp"
                android:background="@drawable/bottombarrounded"
                android:gravity="center">

                <EditText
                    android:id="@+id/activity_main_edit_text"
                    android:layout_width="0dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/edittextrounded"
                    android:hint="@string/edit_text_hint"
                    android:inputType="textCapSentences|textMultiLine"
                    android:maxLength="2000"
                    android:maxLines="4"
                    android:paddingLeft="32dp"
                    android:textColor="@color/black"
                    android:textColorHint="@color/edit_text_color" />

                <Button
                    android:id="@+id/activity_main_post_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="64dp"
                    android:background="@drawable/roundedbutton"
                    android:text="@string/post_button"
                    android:textColor="@color/text_color"
                    android:textSize="20sp"
                    android:textStyle="bold" />

            </LinearLayout>

        </FrameLayout>
    </LinearLayout>
</layout>

What Should I Do ?

2
Could you please provide an activity_main.xml code?Blind Kai
Clean up the layout code with xmlns and don't pass the context 2 times. So delete tools:context=".MainActivity"Blind Kai

2 Answers

0
votes

Remove this line from your LinearLayout properties:

tools:context=".MainActivity"

You don't need to pass the context. It has already got the context and you are trying to pass it again. Hence a duplicate attribute.

Also, remove the xmlns attributes you are using. It causes the error too. Remove these lines:

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"

Delete this too:

xmlns:android="http://schemas.android.com/apk/res/android"
0
votes

Remove this line from LinearLayout:

xmlns:app="http://schemas.android.com/apk/res-auto"

It is not needed as it is already at the top of the XML file.