Credntia / MVBarcodeReader

A Barcode scanner library for Android. Uses the Google Play Services' mobile vision api for barcode detection.
Apache License 2.0
68 stars 22 forks source link

java.lang.RuntimeException: CameraSource.updateRotation getParameters failed (empty parameters) #43

Open valeriobottone-milkman opened 4 years ago

valeriobottone-milkman commented 4 years ago

I have an app that uses barcode reading, but sometimes especially with Huawei devices, I find this crash.

Fatal Exception: java.lang.RuntimeException: getParameters failed (empty parameters) at android.hardware.Camera.native_getParameters(Camera.java) at android.hardware.Camera.getParameters(Camera.java:3078) at online.devliving.mobilevisionpipeline.camera.CameraSource.updateRotation(CameraSource.java:1012) at online.devliving.mobilevisionpipeline.camera.CameraSourcePreview.onConfigurationChanged(CameraSourcePreview.java:153) at android.view.View.dispatchConfigurationChanged(View.java:10553) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1336) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1340) at android.view.ViewRootImpl.updateConfiguration(ViewRootImpl.java:3752) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3909) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6255) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

I've probably figured out where it comes from, but I don't know how to solve it. I insert the part of the code that should make this problem arise.

builder = builder.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);

I believe that some devices don't notify the event "onFocusChanged" and this could bring the crash for the continued search of focus about the CameraSource. Could someone help me solve the issue?