Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int, android.graphics.PorterDuff$Mode)' on a null object reference
You can use the app sample to simulate the error.
After the photo editor start, if we click on the "Clear All" button as the first action on the editor the following error happen:
2019-05-14 13:17:52.297 11032-11032/com.ahmedadeltito.photoeditor E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ahmedadeltito.photoeditor, PID: 11032
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int, android.graphics.PorterDuff$Mode)' on a null object reference
at com.ahmedadeltito.photoeditorsdk.BrushDrawingView.clearAll(BrushDrawingView.java:121)
at com.ahmedadeltito.photoeditorsdk.PhotoEditorSDK.clearAllViews(PhotoEditorSDK.java:184)
at com.ahmedadeltito.photoeditor.PhotoEditorActivity.clearAllViews(PhotoEditorActivity.java:216)
at com.ahmedadeltito.photoeditor.PhotoEditorActivity.onClick(PhotoEditorActivity.java:340)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
hey man i can't complie that library can u send me your working project
I dont have the project anymore, I was just testing the lib.
But I created a new project and copied and pasted any code, file and configuration from the sample to my project to get it working :(
Hey do you have any photo editing project? Because i'm facing problems in this area.
Sorry, I dont.
@kleysonr
please update this method
void clearAll() {
if(drawCanvas!=null){
drawCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
invalidate();
}
}
in BrushDrawingView class and it will fix it