java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Stack Overflow by W. Vincent
, 1 year ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
via Stack Overflow by Unknown author, 2 years ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
via Stack Overflow by user8780097
, 1 month ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
via Stack Overflow by Karolis Kursevičius
, 4 months ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
via Stack Overflow by tadvas
, 1 year ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference 10-13 21:17:19.298:
via Stack Overflow by lionheart
, 8 months ago
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at android.widget.Toast.(Toast.java:102)
at android.widget.Toast.makeText(Toast.java:259)
at com.example.nkwpy.myapplication.MainFragment.query(MainFragment.java:176)
at com.example.nkwpy.myapplication.MainFragment.access$000(MainFragment.java:46)
at com.example.nkwpy.myapplication.MainFragment$queryListener.onClick(MainFragment.java:161)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21177)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)

Users with the same issue

13 times, 5 months ago
7 times, 9 months ago
4 times, 1 year ago
4 times, 1 year ago
Once, 1 year ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.