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.

Popular Posts