Getting Camera error in Zxing Barcode Application Getting Camera error in Zxing Barcode Application android android

Getting Camera error in Zxing Barcode Application


For Android 6+, because of the "permission" issue, If you got the message "Sorry, the camera encountered a problem. You may need to restart the device.", go to Settings - Apps - find "your app name" - select Permissions and switch on "Camera".


permission of camera

<uses-permission android:name="android.permission.CAMERA"

is not at proper place. it should be after application tag.


This means the device returned null from Camera.open() and it shouldn't ever do that. It's treated as a device bug. I am not sure how you would debug why it is doing this, but that's the cause.

The only time I have seen this happen consistently is on Android 2.2 devices that have a front camera, only. The API for accessing a front camera only appeared in Android 2.3, and the previous Camera.open() API method may only return a rear-facing camera. So these return null. And it is a device bug, really, since they really need to be running Android 2.3 to let apps use a front camera.