Barburka
Barburka

Reputation: 465

Attribute android:id is not allowed here in new kotlin project in activity_main.xml

I get errors in new Android Studio project in Kotlin connected with attributes: 'Attribute android:x is not allowed here"

file: activity_main.xml

<?xml version="1.0" encoding="utf-8" ?>
<androidx.drawerlayout.widget.DrawerLayout xmlns="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://www.w3.org/1999/XSL/Transform"
    android:id="@+id/drawer_layout" #here
    android:layout_width="match_parent" #here
    android:layout_height="match_parent" #here
    android:fitsSystemWindows="true" #here
    tools:openDrawer="start"> #here

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent" #here
        android:layout_height="match_parent" /> #here

    <com.google.android.material.navigation.NavigationView #here
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

Upvotes: 2

Views: 1853

Answers (3)

Eshy
Eshy

Reputation: 21

Have you tried to rebuild or clean your project? I think you should try that then run the app again

Upvotes: 0

jsamol
jsamol

Reputation: 3232

Try syncing project with Gradle files: File -> Sync project with Gradle files.

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1007554

In your root element, replace:

xmlns:android="http://www.w3.org/1999/XSL/Transform"

with:

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

Also, remove xmlns="http://schemas.android.com/apk/res/android" from your root element.

Upvotes: 1

Related Questions