0
    TextView drawerName = (TextView) findViewById(R.id.drawerName);
    TextView drawerEmail = (TextView) findViewById(R.id.drawerEmail);
    CircleImageView drawerAvatar = (CircleImageView) findViewById(R.id.drawerAvatar);

    drawerName.setText(personName);
    drawerEmail.setText(personEmail);

FATAL EXCEPTION: main Process: com.mje.dev.liqourstore, PID: 1537 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mje.dev.liqourstore/com.mje.dev.liqourstore.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248) at android.app.ActivityThread.access$1000(ActivityThread.java:197) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6872) 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:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at com.mje.dev.liqourstore.MainActivity.onCreate(MainActivity.java:146) at android.app.Activity.performCreate(Activity.java:6550) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)  at android.app.ActivityThread.access$1000(ActivityThread.java:197)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:6872)  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:1404)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

starkshang
  • 8,228
  • 6
  • 41
  • 52
  • 2
    Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – starkshang Jan 26 '16 at 07:56
  • from you error log,we can see your drawerName or drawerEmail is null,please check these first. – starkshang Jan 26 '16 at 07:56
  • I think he's just a new person come to Android. Post a link like "What is null pointer exception" doesn't help him. Close this post doesn't help him either. And nonsense,too. He correctly post a code that he sees error. – hqt Jan 26 '16 at 11:50
  • Please post your layout file for this view. – hqt Jan 26 '16 at 11:51

2 Answers2

0

It looks like that you haven't set the View of Activity by setting contentView as setContentView. Furthermore, please also check that setContentView layout also have the textview you are fetching.

hope this helps.

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
0
    TextView drawerName = (TextView) navigationView.getHeaderView(0).findViewById(R.id.navDrawerName);
    TextView drawerEmail = (TextView) navigationView.getHeaderView(0).findViewById(R.id.navDrawerEmail);
    CircleImageView  drawerAvatar = (CircleImageView) navigationView.getHeaderView(0).findViewById(R.id.avatar);