terrylinla / react-native-sketch-canvas

A React Native component for drawing by touching on both iOS and Android.
MIT License
697 stars 453 forks source link

Error attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference #67

Closed dhanangpratama closed 6 years ago

dhanangpratama commented 6 years ago

I got this error when using custom UI. below the code for save image:

<SketchCanvas ref={ref => this.canvas = ref} style={{ flex: 1 }} strokeColor={this.state.strokeColor} strokeWidth={this.state.strokeSize}

and the save method:

`<TouchableOpacity onPress={() => { this.canvas.save('jpg', true, '', 'test', true, true) }} style={styles.btn}>

                    </TouchableOpacity>`

Any wrong with my code? Thank you! ^__^

ggunti commented 6 years ago

Same error at me

ggunti commented 6 years ago

I found the problem. The documentation say that save function look like this: save(imageType, transparent, folder, filename, includeImage, cropToImageSize), but it actually is save(imageType, transparent, folder, filename, includeImage, includeText, cropToImageSize). Is missing the includeText parameter from documentation.

So in your case you could change this.canvas.save('jpg', true, '', 'test', true, true) to this.canvas.save('jpg', true, '', 'test', true, false, true) and it should work.

dhanangpratama commented 6 years ago

Thank you @ggunti, you save my life! ^__^