java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setBackground(android.graphics.drawable.Drawable)' on a null object reference

Stack Overflow | MLN | 2 weeks ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to Rafael Fischer Viola . Or join the community to write better ones.
  1. 0

    Android Changing a Normal Layout to Tab Layout error in Image buttons and other?

    Stack Overflow | 2 weeks ago | MLN
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setBackground(android.graphics.drawable.Drawable)' on a null object reference
  2. 0
    samebug tip
    If you're using nested fragments, you have to use childFragmentManager instead of fragmentManager.
  3. 0
    samebug tip
    You can't use hide() or remove() or many things with NULL values, try checking for NULL before calling this methods.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    Also, check if you're not using android.support.v4.app.FragmentTransaction with android.app.Fragment and vice-versa

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void android.widget.ImageView.setBackground(android.graphics.drawable.Drawable)' on a null object reference

      at star.yx.tabview.ProfileFragment.updatePlayStatus()
    2. star.yx.tabview
      ProfileFragment.onCreateView
      1. star.yx.tabview.ProfileFragment.updatePlayStatus(ProfileFragment.java:370)
      2. star.yx.tabview.ProfileFragment.setIFace(ProfileFragment.java:205)
      3. star.yx.tabview.ProfileFragment.onCreateView(ProfileFragment.java:158)
      3 frames
    3. Android Support v4
      ViewPager.onMeasure
      1. android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      2. android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      3. android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      4. android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      5. android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      6. android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      7. android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      8. android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      9. android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      10. android.support.v4.view.ViewPager.populate(ViewPager.java:1116)
      11. android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642)
      11 frames
    4. Android Platform
      FrameLayout.onMeasure
      1. android.view.View.measure(View.java:18596)
      2. android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
      3. android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
      4. android.view.View.measure(View.java:18596)
      5. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
      6. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      6 frames
    5. Android v7
      ContentFrameLayout.onMeasure
      1. android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
      1 frame
    6. Android Platform
      ViewGroup.measureChildWithMargins
      1. android.view.View.measure(View.java:18596)
      2. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
      2 frames
    7. Android v7
      ActionBarOverlayLayout.onMeasure
      1. android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393)
      1 frame
    8. Android Platform
      FrameLayout.onMeasure
      1. android.view.View.measure(View.java:18596)
      2. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
      3. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      4. android.view.View.measure(View.java:18596)
      5. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
      6. android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
      7. android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
      8. android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
      9. android.view.View.measure(View.java:18596)
      10. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
      11. android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
      11 frames
    9. Android
      PhoneWindow$DecorView.onMeasure
      1. com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2897)
      1 frame
    10. Android Platform
      ActivityThread.main
      1. android.view.View.measure(View.java:18596)
      2. android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2248)
      3. android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1306)
      4. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1548)
      5. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
      6. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642)
      7. android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
      8. android.view.Choreographer.doCallbacks(Choreographer.java:590)
      9. android.view.Choreographer.doFrame(Choreographer.java:560)
      10. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
      11. android.os.Handler.handleCallback(Handler.java:739)
      12. android.os.Handler.dispatchMessage(Handler.java:95)
      13. android.os.Looper.loop(Looper.java:145)
      14. android.app.ActivityThread.main(ActivityThread.java:5951)
      14 frames
    11. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    12. Android
      ZygoteInit$MethodAndArgsCaller.run
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
      1 frame