java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.LinearGradient.setLocalMatrix(android.graphics.Matrix)' on a null object reference

GitHub | yuanshuaiding | 7 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    直接使用rainbow动画样式会报NullPointException

    GitHub | 7 months ago | yuanshuaiding
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.LinearGradient.setLocalMatrix(android.graphics.Matrix)' on a null object reference
  2. 0

    GitHub comment 33#245207667

    GitHub | 6 months ago | YuFong
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.LinearGradient.setLocalMatrix(android.graphics.Matrix)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void android.graphics.LinearGradient.setLocalMatrix(android.graphics.Matrix)' on a null object reference

      at com.hanks.htextview.animatetext.RainBowText.drawFrame()
    2. com.hanks.htextview
      HTextView.onDraw
      1. com.hanks.htextview.animatetext.RainBowText.drawFrame(RainBowText.java:49)
      2. com.hanks.htextview.animatetext.HText.onDraw(HText.java:80)
      3. com.hanks.htextview.HTextView.onDraw(HTextView.java:112)
      3 frames
    3. Android Platform
      FrameLayout.draw
      1. android.view.View.draw(View.java:16468)
      2. android.view.View.updateDisplayListIfDirty(View.java:15398)
      3. android.view.View.getDisplayList(View.java:15420)
      4. android.view.View.draw(View.java:16190)
      5. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      6. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      7. android.view.View.updateDisplayListIfDirty(View.java:15393)
      8. android.view.View.getDisplayList(View.java:15420)
      9. android.view.View.draw(View.java:16190)
      10. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      11. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      12. android.view.View.updateDisplayListIfDirty(View.java:15393)
      13. android.view.View.getDisplayList(View.java:15420)
      14. android.view.View.draw(View.java:16190)
      15. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      16. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      17. android.view.View.updateDisplayListIfDirty(View.java:15393)
      18. android.view.View.getDisplayList(View.java:15420)
      19. android.view.View.draw(View.java:16190)
      20. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      21. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      22. android.view.View.updateDisplayListIfDirty(View.java:15393)
      23. android.view.View.getDisplayList(View.java:15420)
      24. android.view.View.draw(View.java:16190)
      25. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      26. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      27. android.view.View.updateDisplayListIfDirty(View.java:15393)
      28. android.view.View.getDisplayList(View.java:15420)
      29. android.view.View.draw(View.java:16190)
      30. android.view.ViewGroup.drawChild(ViewGroup.java:3713)
      31. android.view.ViewGroup.dispatchDraw(ViewGroup.java:3506)
      32. android.view.View.draw(View.java:16471)
      33. android.widget.FrameLayout.draw(FrameLayout.java:598)
      33 frames
    4. Android
      PhoneWindow$DecorView.draw
      1. com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:3107)
      1 frame
    5. Android Platform
      ActivityThread.main
      1. android.view.View.updateDisplayListIfDirty(View.java:15398)
      2. android.view.View.getDisplayList(View.java:15420)
      3. android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:310)
      4. android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:316)
      5. android.view.ThreadedRenderer.draw(ThreadedRenderer.java:355)
      6. android.view.ViewRootImpl.draw(ViewRootImpl.java:2925)
      7. android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2722)
      8. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2309)
      9. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1298)
      10. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6982)
      11. android.view.Choreographer$CallbackRecord.run(Choreographer.java:821)
      12. android.view.Choreographer.doCallbacks(Choreographer.java:606)
      13. android.view.Choreographer.doFrame(Choreographer.java:576)
      14. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:807)
      15. android.os.Handler.handleCallback(Handler.java:739)
      16. android.os.Handler.dispatchMessage(Handler.java:95)
      17. android.os.Looper.loop(Looper.java:145)
      18. android.app.ActivityThread.main(ActivityThread.java:6872)
      18 frames
    6. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    7. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
      2 frames