title: Bottom Navigation does not work and leads to app crash
body: <p>I have tried to use Bottom Navigation on my application but it doesn't work and application keep crash.
  here is my main activity:</p>
  
  <pre><code>package com.example.testing;
  
  import android.support.annotation.NonNull;
  import android.support.design.widget.BottomNavigationView;
  import android.support.v4.app.Fragment;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.MenuItem;
  
  public class MainActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener {
  
          @Override
          protected void onCreate (Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
              loadFragment(new HomeFragment());
              BottomNavigationView navigation = findViewById(R.id.navigation);
              navigation.setOnNavigationItemSelectedListener(this);
      }
  
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
              Fragment fragment = null;
  
              switch (item.getItemId()) {
                  case R.id.homePage:
                      fragment = new HomeFragment();
                      break;
  
                  case R.id.chat:
                      fragment = new ChatFragment();
                      break;
              }
  
              return loadFragment(fragment);
          }
  
          private boolean loadFragment(Fragment fragment) {
              if (fragment != null) {
                  getSupportFragmentManager()
                          .beginTransaction()
                          .replace(R.id.fragment_container, fragment)
                          .commit();
                  return true;
              }
              return false;
          }
      }
  </code></pre>
  
  <p>and here is my xml file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
      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:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;FrameLayout
          android:id="@+id/fragment_container"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_marginBottom="56dp"
          android:text="@string/title_home"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;android.support.design.widget.BottomNavigationView
          android:id="@+id/navigation"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginStart="0dp"
          android:layout_marginEnd="0dp"
          android:background="?android:attr/windowBackground"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:menu="@menu/menu_nav" /&gt;
  
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>also, I create a two fragment for the navigation, both have the same xml and class code </p>
  
  <p>the fragment xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:text="Home"
          android:textAppearance="@style/Base.TextAppearance.AppCompat.Large" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>the  fragment class :</p>
  
  <pre><code>package com.example.testing;
  
  public class HomeFragment extends Fragment {
      @Nullable
  
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          return inflater.inflate(R.layout.fragment_home, null);
  
      }
  }
  </code></pre>
  
  <p>Also I have added this code to my build.gradle </p>
  
  <pre><code>implementation 'com.android.support:design:28.0.0'
  </code></pre>
  
  <p>BUT here what I got in my logcat : </p>
  
  <pre><code>    --------- beginning of crash
  2019-04-05 21:55:34.150 3169-3169/com.example.testing E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.testing, PID: 3169
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testing/com.example.testing.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.BottomNavigationView
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
          at android.app.ActivityThread.-wrap11(Unknown Source:0)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6494)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
       Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.BottomNavigationView
       Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.support.design.widget.BottomNavigationView
       Caused by: java.lang.reflect.InvocationTargetException
          at java.lang.reflect.Constructor.newInstance0(Native Method)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
          at android.view.LayoutInflater.createView(LayoutInflater.java:647)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
          at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
          at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
          at com.example.testing.MainActivity.onCreate(MainActivity.java:15)
          at android.app.Activity.performCreate(Activity.java:7009)
          at android.app.Activity.performCreate(Activity.java:7000)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
          at android.app.ActivityThread.-wrap11(Unknown Source:0)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
          at android.os.Handler.dispatchMessage(Handler.java:106)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6494)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
       Caused by: android.view.InflateException: Couldn't resolve menu item onClick handler chat in class com.example.testing.MainActivity
          at android.support.v7.view.SupportMenuInflater$InflatedOnMenuItemClickListener.&lt;init&gt;(SupportMenuInflater.java:254)
          at android.support.v7.view.SupportMenuInflater$MenuState.setItem(SupportMenuInflater.java:482)
          at android.support.v7.view.SupportMenuInflater$MenuState.addItem(SupportMenuInflater.java:530)
          at android.support.v7.view.SupportMenuInflater.parseMenu(SupportMenuInflater.java:206)
          at android.support.v7.view.SupportMenuInflater.inflate(SupportMenuInflater.java:128)
          at android.support.design.widget.BottomNavigationView.inflateMenu(BottomNavigationView.java:252)
          at android.support.design.widget.BottomNavigationView.&lt;init&gt;(BottomNavigationView.java:187)
  2019-04-05 21:55:34.152 3169-3169/com.example.testing E/AndroidRuntime:     at android.support.design.widget.BottomNavigationView.&lt;init&gt;(BottomNavigationView.java:114)
              ... 26 more
       Caused by: java.lang.NoSuchMethodException: chat [interface android.view.MenuItem]
          at java.lang.Class.getMethod(Class.java:2068)
          at java.lang.Class.getMethod(Class.java:1690)
          at android.support.v7.view.SupportMenuInflater$InflatedOnMenuItemClickListener.&lt;init&gt;(SupportMenuInflater.java:250)
              ... 33 more
  </code></pre>
  
  <p>PLEASE HELP </p>
  
  <p>HERE is the menu xml : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
  
      &lt;item android:id="@+id/chat"
          android:icon="@drawable/chaticon"
          android:onClick="chat"
          android:title="" /&gt;
  
  
      &lt;item android:id="@+id/homePage"
          android:icon="@drawable/homeicon"
          android:onClick="homepage"
          android:title="" /&gt;
  
  
  &lt;/menu&gt;
  </code></pre>