java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
Opened this issue · 8 comments
Hi.
With new version of gradle build tools got this exception
'com.android.tools.build:gradle:4.1.0'
E/UncaughtException: java.lang.RuntimeException: Unable to destroy activity {view.activity.ActivityBarcodeReader}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5111)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5140)
at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference
at info.androidhive.barcode.camera.CameraSource$FrameProcessingRunnable.release(CameraSource.java:1102)
at info.androidhive.barcode.camera.CameraSource.release(CameraSource.java:327)
at info.androidhive.barcode.camera.CameraSourcePreview.release(CameraSourcePreview.java:83)
at info.androidhive.barcode.BarcodeReader.onDestroy(BarcodeReader.java:303)
at androidx.fragment.app.Fragment.performDestroy(Fragment.java:2830)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1028)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy(FragmentManagerImpl.java:2644)
at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:329)
at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:366)
at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:242)
at view.activity.ActivityBase.onDestroy(ActivityBase.kt:162)
@azzaxx Have you managed to fix this issue?
having same issue in on destroy activity , any fix would help thank you
if anyone solves it please write your solution
have anyone solved it? please write your solution
Hey guys I hope everyone is doing great.
Recently I have also faced this Bug and solved it. I have made the Pull Request for this bug.
In the meantime, if you want to fix it temporarily till @ravi8x merges the PR you can do the following.
- Download or Cloned the Library.
- Import this Library as a module in your Project.
- When completing steps 1 & 2 now go to
CameraSource.java
class. - Remove this line
assert (mProcessingThread.getState() == State.TERMINATED);
It will fix the bug.
Thanks!
I recently solved this error by uploading the same repository and making the adjustment since it has not received updates for a while, you just change the name of the package and that's it
I recently solved this error by uploading the same repository and making the adjustment since it has not received updates for a while, you just change the name of the package and that's it
This resolve my app crash issue.
why was the line -
assert (mProcessingThread.getState() == Thread.State.TERMINATED);
was there in the first place.
I first added a null check for mProcessingThread before the line, it fixed the crash, later i realised this line was not at all needed. As before release method is called =, stop() was already callled and mProcessingThread is actually set null.