MobileVisionBarcodeScanner icon indicating copy to clipboard operation
MobileVisionBarcodeScanner copied to clipboard

Unable to destroy activity null pointer exception at barcodecapture.ondestroy

Open Ssehgal29 opened this issue 4 years ago • 8 comments

whenever i call onbackpressed or perform an intent the app crashes and show the error unable to destroy the activity Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference.

Ssehgal29 avatar Nov 05 '20 10:11 Ssehgal29

@Ssehgal29 were you able to get around this??

damms005 avatar Dec 14 '20 13:12 damms005

Yess it's because of gradle incompatibility... Just go to project structure and set your gradle to 4.0.0 and everything works perfectly.

Ssehgal29 avatar Dec 14 '20 14:12 Ssehgal29

@damms005 were you able to get around this??

KushalMehta1995 avatar Feb 04 '21 11:02 KushalMehta1995

@Ssehgal29 were you able to get around this?? It's not working in my case.

KushalMehta1995 avatar Feb 04 '21 11:02 KushalMehta1995

@Kush1195 Yes. I had to clone this repo locally and rebuild the app locally, and included it in my app as a local library dependency (from my project's graddle settings)

damms005 avatar Feb 10 '21 15:02 damms005

@Kush1195 Yes. I had to clone this repo locally and rebuild the app locally, and included it in my app as a local library dependency (from my project's graddle settings)

Please Do soon. Thank You

KushalMehta1995 avatar Mar 05 '21 13:03 KushalMehta1995

Any update on this issue. How can we fix this.. i tried to change gradle to 4.0.0 still not working. please let me know if any one fixed and the related all gradle configurations . I used this library in a flutter plugin https://pub.dev/packages/mvbarcodescan. Now i am getting this crash issue

kprathap23 avatar Jul 31 '22 05:07 kprathap23

To anyone still having this problem, hopefully this helps. I was trying to get around this for hours, and the solution I found was this:

protected void onDestroy(){
        try {
            super.onDestroy();
        } catch (Exception e) {
            super.finishAndRemoveTask();
        }
    }
}

The class I was using would throw this error every time it got destroyed (super.onDestroy() was called), and it had something to do with the onDestroy methods being inherited by this repo. I was able to just catch the exception and run this random function to finish the task after the error was thrown. So far after my testing, this solution has held up.

Hopefully this can help, or give you direction to fix it!

Note: This worked for Gradle version 8.0.2

Fqceless avatar Mar 10 '23 05:03 Fqceless