Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int, android.graphics.PorterDuff$Mode)' on a null object reference #33

Open
kleysonr opened this issue May 14, 2019 · 5 comments

Comments

@kleysonr
Copy link

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)

@Himanshu507
Copy link

hey man i can't complie that library can u send me your working project

@kleysonr
Copy link
Author

kleysonr commented Jul 1, 2019

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 :(

@Himanshu507
Copy link

Hey do you have any photo editing project? Because i'm facing problems in this area.

@kleysonr
Copy link
Author

kleysonr commented Jul 1, 2019

Sorry, I dont.

@mrabelwahed
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants