Closed EArminjon closed 4 years ago
I clone git@github.com:mintware-de/flutter_barcode_reader.git and run the example on my emulator, same issue...
I test several emulator, app work when api >= 27 (Android 8.1)...
Looks like this issue is related to https://github.com/dm77/barcodescanner/issues/208
I'm having same problem on API 23 emulator. I see that dm77/barcodescanner#208 is an old issue and it seems no one is looking at that.
In kotlin class ZXingAutofocusScannerView I inserted a try-catch to bypass error
override fun setAutoFocus(state: Boolean) {
try {
super.setAutoFocus(callbackFocus)
} catch (ex: Exception) {
}
}
It's just a workaround and actually I don't know if this create any other problem but now app isn't crashing anymore on cancelAutoFocus and it seems it's running smooth.
@prokons feel free to create a PR
I have the same problem on an eumlated AVD device (API 24). I found this solution:
//solution found on https://stackoverflow.com/a/9127845/6395540
Camera.Parameters p = mCamera.getParameters();
List<String> focusModes = p.getSupportedFocusModes();
if(focusModes != null && focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
//Phone supports autofocus!
}
else {
//Phone does not support autofocus!
}
I thinkthat a good thing can be insert the control inside the method that run setAutoFocus method (ZXingAutofocusScannerView.kt:26) and print log on autofocus failure instead of throwing the exception.
@oznecniV97 I think your solution is better and more complete than mine. I just don't know how to pass mCamera to setAutoFocus method without breaking the override
Add the fix as merge request (https://github.com/mintware-de/flutter_barcode_reader/pull/228)
Merged
Describe the bug My emulator crash when use BarcodeScanner.scan();
Screenshots If applicable, add screenshots to help explain your problem.
Logs
Environment :