Solved - Bizarre null pointer thrown in Canvas' throwIfRecycled

In android, getting bizarre null pointer errors related to recycled bitmaps?  Maybe something like this?

E/AndroidRuntime(13082): FATAL EXCEPTION: main
E/AndroidRuntime(13082): java.lang.NullPointerException
E/AndroidRuntime(13082): at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) E/AndroidRuntime(13082): at android.graphics.Canvas.drawBitmap(Canvas.java:1012) E/AndroidRuntime(13082): at yourapp.draw(YourView.java:NN)


where at line NN your code is doing something like

canvas.drawBitmap(yourBitmap, null, dst,null);


Try doing a clean in eclipse. It seems to be caching sometimes and can get confused. That seemed to solve it for this particular case.

4 comments:

  1. Solved my issue! Thanks!

    ReplyDelete
  2. Same here, nice post.

    ReplyDelete
  3. salut a tous,j'ai teste mai il reste le même erreur !!!
    help...
    merci

    ReplyDelete
  4. Awesome, thanks! That fixed it.

    ReplyDelete

Popular Posts