java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

Stack Overflow | Noumaan Naseer | 5 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    How to communicate with fragments in Android Studio2.0?

    Stack Overflow | 5 months ago | Noumaan Naseer
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference

      at com.example.nouma.life.FirstFragment.<init>()
    2. com.example.nouma
      MainActivity.onNavigationItemSelected
      1. com.example.nouma.life.FirstFragment.<init>(FirstFragment.java:35)
      2. com.example.nouma.life.MainActivity.onNavigationItemSelected(MainActivity.java:106)
      2 frames
    3. android.support.design
      NavigationView$1.onMenuItemSelected
      1. android.support.design.widget.NavigationView$1.onMenuItemSelected(NavigationView.java:153)
      1 frame
    4. android.support.v7
      MenuBuilder.performItemAction
      1. android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810)
      2. android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
      3. android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957)
      3 frames
    5. android.support.design
      NavigationMenuPresenter$1.onClick
      1. android.support.design.internal.NavigationMenuPresenter$1.onClick(NavigationMenuPresenter.java:328)
      1 frame
    6. Android Platform
      ActivityThread.main
      1. android.view.View.performClick(View.java:4759)
      2. android.view.View$PerformClick.run(View.java:19770)
      3. android.os.Handler.handleCallback(Handler.java:739)
      4. android.os.Handler.dispatchMessage(Handler.java:95)
      5. android.os.Looper.loop(Looper.java:135)
      6. android.app.ActivityThread.main(ActivityThread.java:5237)
      6 frames
    7. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    8. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
      2 frames