title: how to resolve cannot find NavigationView
body: <p>I am a beginner in android development and I have encountered some difficulty in using the navigation drawer. I am developing an app with a navigation drawer on the left side. But when I add the navigation view to the xml file of the Main activity, it gives this error message:</p>
  
  <pre><code>Class referenced in the layout file, com.google.android.material.navigation.NavigationView, was not found in the project or the libraries 
  Cannot resolve class com.google.android.material.navigation.NavigationView 
  </code></pre>
  
  <p>This is my code for the Main activity:</p>
  
  <pre><code>package com.hfad.catchat;
  
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.fragment.app.Fragment;
  import androidx.fragment.app.FragmentTransaction;
  
  import android.os.Bundle;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Fragment fragment = new InboxFragment();
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          ft.add(R.id.content_frame, fragment);
          ft.commit();
      }
  }
  </code></pre>
  
  <p>This is the xml file of the Main activity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.drawerlayout.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" &gt;
  
          &lt;include
              layout="@layout/toolbar_main"
              android:id="@+id/toolbar" /&gt;
  
          &lt;FrameLayout
              android:id="@+id/content_frame"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;com.google.android.material.navigation.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          app:headerLayout="@layout/nav_header"
          app:menu="@menu/menu_nav" /&gt;
  &lt;/androidx.drawerlayout.widget.DrawerLayout&gt;
  </code></pre>