Fatal Exception: java.lang.IllegalStateException: Access to viewBinding after Lifecycle is destroyed or hasn't created yet. The instance of viewBinding will be not cached.
at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.runStrictModeChecks(ViewBindingProperty.kt:112)
at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:91)
at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:72)
at me.echoist.app.qrScanner.ScanActivity.getViewBinding(ScanActivity.kt:41)
at me.echoist.app.qrScanner.ScanActivity.access$getViewBinding(ScanActivity.kt:28)
at me.echoist.app.qrScanner.ScanActivity$startCamera$1$imageAnalysis$1$1.invoke(ScanActivity.kt:128)
at me.echoist.app.qrScanner.ScanActivity$startCamera$1$imageAnalysis$1$1.invoke(ScanActivity.kt:127)
at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer.analyze$lambda-2(MLKitBarcodeAnalyzer.kt:31)
at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer.$r8$lambda$h9t37u_KA3db4N33zvl7Kb1ftGU()
at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer$$ExternalSyntheticLambda1.onSuccess(:6)
at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.1:1)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
What additional information can I provide? How can I avoid this crash? What checks to do?
You tried to access ViewBinding after Activity's View destroyed. In Activity you have no any way to check state of View. Only get current state of lifecycle
Fatal Exception: java.lang.IllegalStateException: Access to viewBinding after Lifecycle is destroyed or hasn't created yet. The instance of viewBinding will be not cached. at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.runStrictModeChecks(ViewBindingProperty.kt:112) at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:91) at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:72) at me.echoist.app.qrScanner.ScanActivity.getViewBinding(ScanActivity.kt:41) at me.echoist.app.qrScanner.ScanActivity.access$getViewBinding(ScanActivity.kt:28) at me.echoist.app.qrScanner.ScanActivity$startCamera$1$imageAnalysis$1$1.invoke(ScanActivity.kt:128) at me.echoist.app.qrScanner.ScanActivity$startCamera$1$imageAnalysis$1$1.invoke(ScanActivity.kt:127) at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer.analyze$lambda-2(MLKitBarcodeAnalyzer.kt:31) at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer.$r8$lambda$h9t37u_KA3db4N33zvl7Kb1ftGU() at me.echoist.app.qrScanner.MLKitBarcodeAnalyzer$$ExternalSyntheticLambda1.onSuccess(:6) at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.1:1) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7073) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)