Learn to create a Paint Application for Android
Sylvain Saurel

Mr. Saurel,

I am getting a null pointer exception on the path for the FingerPath object after I try to draw something on the canvas. (Tested on the api level 23 emulator.)

I found the raw PaintView class on GitHub and used it in my project but same error occurs on the same line where we try to draw a path on the canvas.

As some stackoverflow threads indicate this is a problem when the custom View is defined in xml layout and it doesn’t use the default constructor and thus some fields are missing on the custom View object. Their suggestion is to call init() method on every constructor to avoid such null fields.

I am not an expert on creating custom Views, especially the ones require a Canvas, so may be you can suggest me something to help with the issue.

Show your support

Clapping shows how much you appreciated Emre Kalayci’s story.