java.lang.RuntimeException: Unable to start activity ComponentInfo{rishabh.example.com.navigationdrawer/rishabh.example.com.navigationdrawer.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference

Stack Overflow | R.K. GUPTA | 8 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Initialize a view of different layout in Main Activity

    Stack Overflow | 8 months ago | R.K. GUPTA
    java.lang.RuntimeException: Unable to start activity ComponentInfo{rishabh.example.com.navigationdrawer/rishabh.example.com.navigationdrawer.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference

      at rishabh.example.com.navigationdrawer.MainActivity.onCreate()
    2. rishabh.example.com
      MainActivity.onCreate
      1. rishabh.example.com.navigationdrawer.MainActivity.onCreate(MainActivity.java:58)
      1 frame
    3. Android Platform
      ActivityThread.performLaunchActivity
      1. android.app.Activity.performCreate(Activity.java:6010)
      2. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
      3. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
      3 frames