title: BottomNavigationView working fine in emulator but crashes app in real mobile
body: <p>I am implementing BottomNavigationView in my app. It works fine in emulator but crashes app when i tried in real mobile. I am also using viewpager in main activity for swipe bottomnavigation items. I check with gradle dependency also but still its crashes. And android version of both the emulator and mobile is same.</p>
  
  <p><strong>Main Activity</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener, Dashboard.OnFragmentInteractionListener, Profile.OnFragmentInteractionListener, Plans.OnFragmentInteractionListener, Test.OnFragmentInteractionListener {
  
  private ViewPager vp_pages;
  MenuItem prevMenuItem;
  private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
          = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        //  android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
        //  android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
          switch (item.getItemId()) {
              case R.id.navigation_dashboard:
                 // fragmentTransaction.replace(R.id.container, new Dashboard()).commit();
                  vp_pages.setCurrentItem(0);
                  return true;
              case R.id.navigation_profile:
                 // fragmentTransaction.replace(R.id.container, new Profile()).commit();
                  vp_pages.setCurrentItem(1);
                  return true;
              case R.id.navigation_test:
                 // fragmentTransaction.replace(R.id.container, new Test()).commit();
                  vp_pages.setCurrentItem(2);
                  return true;
              case R.id.navigation_plans:
                  // fragmentTransaction.replace(R.id.container, new Plans()).commit();
                  vp_pages.setCurrentItem(3);
                  return true;
          }
          return false;
      }
  };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  
      ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
              this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
      drawer.addDrawerListener(toggle);
      toggle.syncState();
  
      NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
  
      final BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
      navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
      BottomNavigationViewHelper.removeShiftMode(navigation);
  
    //  android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
    //  android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    //  fragmentTransaction.replace(R.id.container, new Dashboard()).commit();
  
      vp_pages = (ViewPager) findViewById(R.id.vp_pages);
  
      vp_pages.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  
          }
  
          @Override
          public void onPageSelected(int position) {
              if (prevMenuItem != null) {
                  prevMenuItem.setChecked(false);
              } else {
                  navigation.getMenu().getItem(0).setChecked(false);
              }
              navigation.getMenu().getItem(position).setChecked(true);
              prevMenuItem = navigation.getMenu().getItem(position);
  
          }
  
          @Override
          public void onPageScrollStateChanged(int state) {
  
          }
      });
      setupViewPager(vp_pages);
  }
  
  @Override
  public void onBackPressed() {
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      if (drawer.isDrawerOpen(GravityCompat.START)) {
          drawer.closeDrawer(GravityCompat.START);
      } else {
          super.onBackPressed();
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_logout) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      // Handle navigation view item clicks here.
      int id = item.getItemId();
  
      if (id == R.id.nav_rateus) {
          // Handle the camera action
      } else if (id == R.id.nav_feedback) {
  
      } else if (id == R.id.nav_contactus) {
  
      } else if (id == R.id.nav_share) {
  
      } else if (id == R.id.nav_logout) {
  
      }
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  }
  
  @Override
  public void onFragmentInteraction(Uri uri) {
  
  }
  private void setupViewPager(ViewPager viewPager) {
      ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
      Dashboard dashboard= new Dashboard();
      Profile profile = new Profile();
      Test test = new Test();
      Plans plans = new Plans();
      viewPagerAdapter.addFragment(dashboard);
      viewPagerAdapter.addFragment(profile);
      viewPagerAdapter.addFragment(test);
      viewPagerAdapter.addFragment(plans);
      viewPager.setAdapter(viewPagerAdapter);
  }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout 
  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/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fitsSystemWindows="true"
  tools:openDrawer="start"&gt;
  
  &lt;include
      layout="@layout/app_bar_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  &lt;android.support.design.widget.NavigationView
      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" /&gt;
  
     &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p><strong>app_bar_main.xml</strong></p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout 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"
  tools:context="com.smiles.elearning.MainActivity"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  &lt;include layout="@layout/content_main" /&gt;
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p><strong>content_main.xml</strong></p>
  
  <pre><code>&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:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.smiles.elearning.MainActivity"
  tools:showIn="@layout/app_bar_main"&gt;
  
  &lt;FrameLayout
      android:id="@+id/container"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  &lt;android.support.design.widget.BottomNavigationView
      android:id="@+id/navigation"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginEnd="0dp"
      android:layout_marginStart="0dp"
      android:background="?android:attr/windowBackground"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:menu="@menu/navigation" /&gt;
  
  &lt;android.support.v4.view.ViewPager
      android:id="@+id/vp_pages"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
   &lt;/android.support.v4.view.ViewPager&gt;
   &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>dependency</strong></p>
  
  <pre><code>dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'com.android.support:appcompat-v7:27.0.2'
  implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  implementation 'com.android.support:support-v4:27.0.2'
  implementation 'com.android.support:support-vector-drawable:27.0.2'
  implementation 'com.android.support:recyclerview-v7:27.0.2'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  implementation 'com.android.support:design:27.0.2'
  implementation 'com.android.support:support-v13:27.0.2'
  compile 'com.github.lzyzsd:circleprogress:1.2.1'
  compile 'dev.dworks.libs:volleyplus:+'
  implementation files('libs/YouTubeAndroidPlayerApi.jar')
  }
  </code></pre>
  
  <p><strong>Menifest</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity
          android:name=".SplashScreen"
          android:theme="@style/Theme.Design.Light.NoActionBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".Login"
          android:theme="@style/Theme.Design.Light.NoActionBar" /&gt;
      &lt;activity
          android:name=".Register"
          android:theme="@style/Theme.Design.Light.NoActionBar" /&gt;
      &lt;activity
          android:name=".OTP"
          android:theme="@style/Theme.Design.Light.NoActionBar" /&gt;
      &lt;activity
          android:name=".SelectStandard"
          android:theme="@style/Theme.Design.Light.NoActionBar" /&gt;
      &lt;activity android:name=".Course" /&gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/title_activity_main"
          android:theme="@style/AppTheme.NoActionBar" /&gt;
      &lt;activity android:name=".RegisterDetail" /&gt;
      &lt;activity android:name=".Topics" /&gt;
      &lt;activity android:name=".StudyMaterial" /&gt;
      &lt;activity android:name=".Video"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Logcat</strong></p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.smiles.elearning, PID: 11772
                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smiles.elearning/com.smiles.elearning.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.BottomNavigationView
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
                    at android.app.ActivityThread.access$900(ActivityThread.java:177)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:145)
                    at android.app.ActivityThread.main(ActivityThread.java:5942)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at java.lang.reflect.Method.invoke(Method.java:372)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
                 Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.BottomNavigationView
                    at android.view.LayoutInflater.createView(LayoutInflater.java:640)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933)
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933)
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                    at com.smiles.elearning.MainActivity.onCreate(MainActivity.java:64)
                    at android.app.Activity.performCreate(Activity.java:6289)
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
                    at android.app.ActivityThread.access$900(ActivityThread.java:177) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:145) 
                    at android.app.ActivityThread.main(ActivityThread.java:5942) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at java.lang.reflect.Method.invoke(Method.java:372) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
                 Caused by: java.lang.reflect.InvocationTargetException
                    at java.lang.reflect.Constructor.newInstance(Native Method)
                    at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                    at android.view.LayoutInflater.createView(LayoutInflater.java:614)
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                    at com.smiles.elearning.MainActivity.onCreate(MainActivity.java:64) 
                    at android.app.Activity.performCreate(Activity.java:6289) 
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) 
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
                    at android.app.ActivityThread.access$900(ActivityThread.java:177) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:145) 
                    at android.app.ActivityThread.main(ActivityThread.java:5942) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at java.lang.reflect.Method.invoke(Method.java:372) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
                 Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070083
                    at android.content.res.Resources.getValue(Resources.java:2345)
                    at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:328)
                    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
                    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
                    at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                    at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:491)
                    at android.support.design.internal.BottomNavigationItemView.initialize(BottomNavigationItemView.java:100)
                    at android.support.design.internal.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:281)
                    at android.support.design.internal.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:62)
                    at android.support.design.widget.BottomNavigationView.inflateMenu(BottomNavigationView.java:236)
                    at android.support.design.widget.BottomNavigationView.&lt;init&gt;(BottomNavigationView.java:165)
                    at android.support.design.widget.BottomNavigationView.&lt;init&gt;(BottomNavigationView.java:114)
                    at java.lang.reflect.Constructor.newInstance(Native Method) 
                    at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
                    at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
                    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:933) 
                    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
                    at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
                    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
                    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                    at com.smiles.elearning.MainActivity.onCreate(MainActivity.java:64) 
                    at android.app.Activity.performCreate(Activity.java:6289) 
                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 
                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) 
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
                    at android.app.ActivityThread.access$900(ActivityThread.java:177) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                    at android.os.Looper.loop(Looper.java:145) 
                    at android.app.ActivityThread.main(ActivityThread.java:5942) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at java.lang.reflect.Method.invoke(Method.java:372) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
  </code></pre>