1

I have problem and I can't find the solution ! I use in XML :

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

    <androidx.drawerlayout.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.libraryproject.MainActivity"
      android:background="@android:color/holo_green_dark">

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


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Main"
            android:textSize="50dp"
            android:id="@+id/textView"
            android:layout_marginTop="200dp"
            android:layout_marginLeft="130dp"/>


    </RelativeLayout>

    <android.support.design.widget.NavigationView ------! #32
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/navigation_menu"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_header"
        android:id="@+id/nv">
    </android.support.design.widget.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

And the error show is : android.view.InflateException: Binary XML file line #32: Binary XML file line #32: Error inflating class android.support.design.widget.NavigationView

in app : APP PAGE

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
AbdullahMQ
  • 23
  • 1
  • 4
  • You have the same error explained here https://stackoverflow.com/questions/30709419/error-inflating-class-android-support-design-widget-navigationview – Djaf Oct 08 '19 at 19:30
  • You are using androidx. Use the `com.google.android.material.navigation.NavigationView` – Gabriele Mariotti Oct 08 '19 at 19:35

2 Answers2

7

In your build.gradle there are some errors:

  • the support libraries 29.0.2 and 29.1.1 don't exist
  • you are using androidx and support libraries together and you can't do it.

Then, since you are using the androidx component <androidx.drawerlayout.widget.DrawerLayout you have to use the

<com.google.android.material.navigation.NavigationView
 ...>

instead of android.support.design.widget.NavigationView.

Finally check your App theme. You have to use a Material Component Theme.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
4

Replace android.support.design.widget.NavigationView with com.google.android.material.navigation.NavigationView because you are using AndroidX.

Squti
  • 4,171
  • 3
  • 10
  • 21