java.lang.RuntimeException

Unable to start activity ComponentInfo{com.push.myapplication/com.push.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference

Samebug tips1

The Fragment was destroyed, and getActivity() returned null. Don't destroy the Fragment.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web45864

  • Unable to start activity ComponentInfo{com.push.myapplication/com.push.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
  • Unable to start activity ComponentInfo{com.buckydroid.chat/com.buckydroid.chat.ChatView}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
  • Unable to start activity ComponentInfo{com.example.madelenko.movierating/com.example.madelenko.movierating.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
  • Stack trace

    • java.lang.RuntimeException: Unable to start activity ComponentInfo{com.push.myapplication/com.push.myapplication.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5373) 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:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference at android.widget.ArrayAdapter.init(ArrayAdapter.java:310) at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:153) at com.push.myapplication.TabFragment2.addToList(TabFragment2.java:44) at com.push.myapplication.MainActivity.onCreate(MainActivity.java:59) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown user
    3 times, 1 year ago
    Unknown user
    Once, 1 year ago
    8 times, 7 months ago
    22 times, 8 months ago
    Once, 1 year ago
    4 more bugmates