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


Solutions on the web

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
via Stack Overflow by OliverDeLange
, 1 year ago
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of web
via blogspot.com by Unknown author, 1 year ago
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

Solution icon of stackoverflow
Attempt to invoke virtual method java.lang.String android.content.Context.getPackageName()' on a null object reference

Stack trace

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
	at android.content.ContextWrapper.getPackageName(ContextWrapper.java:133)
	at android.preference.PreferenceManager.getDefaultSharedPreferencesName(PreferenceManager.java:390)
	at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:385)
	at dagger.module.AppModule.providesSharedPreference(AppModule.java:34)
	at dagger.module.AppModule_ProvidesSharedPreferenceFactory.get(AppModule_ProvidesSharedPreferenceFactory.java:23)
	at dagger.module.AppModule_ProvidesSharedPreferenceFactory.get(AppModule_ProvidesSharedPreferenceFactory.java:8)
	at dagger.internal.ScopedProvider.get(ScopedProvider.java:47)
	at ui.DisplayFragment_MembersInjector.injectMembers(DisplayFragment_MembersInjector.java:29)
	at ui.DisplayFragment_MembersInjector.injectMembers(DisplayFragment_MembersInjector.java:8)
	at dagger.component.DaggerAppComponent.inject(DaggerAppComponent.java:45)
	at ui.DisplayFragment.<init>(DisplayFragment.java:37)
	at ui.DisplayFragment.newInstance(DisplayFragment.java:41)
	at ui.MainActivity$MyPagerAdapter.getItem(MainActivity.java:86)
	at android.support.v4.app.FragmentPagerAdapter.instantiateItem(FragmentPagerAdapter.java:101)
	at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1034)
	at android.support.v4.view.ViewPager.populate(ViewPager.java:1182)
	at android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
	at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
	at android.view.View.measure(View.java:19324)
	at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
	at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6113)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:223)
	at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6113)
	at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6113)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:223)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6113)
	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1723)
	at android.widget.LinearLayout.measureVertical(LinearLayout.java:788)
	at android.widget.LinearLayout.onMeasure(LinearLayout.java:648)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6113)
	at android.widget.FrameLayout.onMeasure(FrameLayout.java:223)
	at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2694)
	at android.view.View.measure(View.java:19324)
	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2545)
	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1454)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1709)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1335)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6816)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)
	at android.view.Choreographer.doCallbacks(Choreographer.java:696)
	at android.view.Choreographer.doFrame(Choreographer.java:631)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:880)
	at android.os.Handler.handleCallback(Handler.java:815)
	at android.os.Handler.dispatchMessage(Handler.java:104)
	at android.os.Looper.loop(Looper.java:207)
	at android.app.ActivityThread.main(ActivityThread.java:5896)

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

4 times, 9 months ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
2 times, 1 year ago
2 times, 1 year ago
306 times, 1 year ago
14 more bugmates