title: Android application crashing when running on device but works in emulator
body: <p>Application was working fine on device I just as main launcher mainactivity was set and was working fine with fragments, but I added 2 fragments which doesn't load before selecting their navigation buttons, the application worked perfectly in emulator and started crashing in device showing this error:      </p>
  
  <pre><code>02-18 03:04:28.675 3157-3157/? E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.hscs.ibd.ibdsystem, PID: 3157
   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hscs.ibd.ibdsystem/com.hscs.ibd.ibdsystem.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2436)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
       at android.app.ActivityThread.access$900(ActivityThread.java:170)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5635)
       at java.lang.reflect.Method.invokeNative(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
       at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
       at dalvik.system.NativeStart.main(Native Method)
    Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
       at android.view.LayoutInflater.createView(LayoutInflater.java:626)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
       at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
       at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
       at android.view.LayoutInflater.inflate(Native Method)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
       at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
       at com.hscs.ibd.ibdsystem.MainActivity.onCreate(MainActivity.java:29)
       at android.app.Activity.performCreate(Activity.java:5580)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
       at android.app.ActivityThread.access$900(ActivityThread.java:170) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304) 
       at android.os.Handler.dispatchMessage(Handler.java:102) 
       at android.os.Looper.loop(Looper.java:146) 
       at android.app.ActivityThread.main(ActivityThread.java:5635) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:515) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
       at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
       at dalvik.system.NativeStart.main(Native Method) 
    Caused by: java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.constructNative(Native Method)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
       at android.view.LayoutInflater.createView(LayoutInflater.java:600)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
       at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
       at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
       at android.view.LayoutInflater.inflate(Native Method) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
       at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) 
       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) 
       at com.hscs.ibd.ibdsystem.MainActivity.onCreate(MainActivity.java:29) 
       at android.app.Activity.performCreate(Activity.java:5580) 
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400) 
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
       at android.app.ActivityThread.access$900(ActivityThread.java:170) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304) 
       at android.os.Handler.dispatchMessage(Handler.java:102) 
       at android.os.Looper.loop(Looper.java:146) 
       at android.app.ActivityThread.main(ActivityThread.java:5635) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:515) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
       at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
       at dalvik.system.NativeStart.main(Native Method) 
    Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f02003f
       at android.content.res.Resources.getValue(Resources.java:2326)
       at android.content.res.Resources.getDrawable(Resources.java:1891)
       at android.content.res.XResources.getDrawable(XResources.java:521)
       at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
       at android.support.v7.internal.widget.TintManager.getDrawable(TintManager.java:145)
       at android.support.v7.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:422)
       at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.prepareMenuItems(NavigationMenuPresenter.java:383)
       at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.&lt;init&gt;(NavigationMenuPresenter.java:255)
       at android.support.design.internal.NavigationMenuPresenter.getMenuView(NavigationMenuPresenter.java:97)
       at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:149)
       at android.support.design.widget.NavigationView.&lt;init&gt;(NavigationView.java:88)
       at java.lang.reflect.Constructor.constructNative(Native Method) 
       at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
       at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
       at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
       at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
       at android.view.LayoutInflater.inflate(Native Method) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
       at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
       at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) 
       at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) 
       at com.hscs.ibd.ibdsystem.MainActivity.onCreate(MainActivity.java:29) 
       at android.app.Activity.performCreate(Activity.java:5580) 
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400) 
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495) 
       at android.app.ActivityThread.access$900(ActivityThread.java:170) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304) 
       at android.os.Handler.dispatchMessage(Handler.java:102) 
       at android.os.Looper.loop(Looper.java:146) 
       at android.app.ActivityThread.main(ActivityThread.java:5635) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:515) 
  </code></pre>
  
  <p>UPDATE:
  MainActivity code as below:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
      implements NavigationView.OnNavigationItemSelectedListener {
  
  private boolean loggedIn=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.setDrawerListener(toggle);
      toggle.syncState();
  
      NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
  
      Fragment myFragment= new custProductFrag();
      android.support.v4.app.FragmentManager fragmentManager= getSupportFragmentManager();
      fragmentManager.beginTransaction()
              .replace(R.id.content,myFragment)
              .commit();
  }
  
  @Override
  protected void onResume() {
      super.onResume();
  
      SharedPreferences sharedPreferences= getSharedPreferences(Config.SHARED_PREF_NAME, Context.MODE_PRIVATE);
      loggedIn=sharedPreferences.getBoolean(Config.LOGGEDIN_SHARED_PREF,false);
  
  
  
      if(loggedIn &amp;&amp; sharedPreferences.getString(Config.TYPE_SHARED_PREF,"").equalsIgnoreCase("customer"))
      {
          Intent intent= new Intent(MainActivity.this,drawer.class);
          startActivity(intent);
      }
      if(loggedIn &amp;&amp; sharedPreferences.getString(Config.TYPE_SHARED_PREF,"admin")=="admin")
      {
          Intent intent = new Intent(MainActivity.this,adminmain.class);
          startActivity(intent);
      }
  }
  
  @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_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
      // Handle navigation view item clicks here.
      int id = item.getItemId();
      Fragment myFragment= new custProductFrag();
  
      if (id == R.id.nav_products) {
          // Handle the camera action
      } else if (id == R.id.nav_aboutus) {
  
      }else if (id == R.id.nav_login) {
          myFragment= new Login();
      } else if (id == R.id.nav_register) {
          myFragment = new register();
  
      }
  
      android.support.v4.app.FragmentManager fragmentManager= getSupportFragmentManager();
      fragmentManager.beginTransaction()
              .replace(R.id.content,myFragment)
              .commit();
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  }
  }
  </code></pre>