Question

I just had a Camera "Error 5001" error while loading a Camera object on my Android app.

E/Camera: Error 5001

I cannot even exit the application with the "home" button, it freezes for 90 seconds. I can't find any documentation regarding that error.

What does 5001 mean?

After 90 seconds, the logcat logs:

W/CameraBase: Camera service died!

Now I can't run the app normally. The screen is green and fails to load the camera.

A reboot fixed that Camera issue, but I would like to know:

  • what actually happened
  • how to avoid it

The device is a Moto X with stock Android 4.4.2.

Thank you for any information.

EDIT

public final class BarcodePreview extends SurfaceView implements SurfaceHolder.Callback {

    private Activity mActivity;
    private SurfaceHolder mSurfaceHolder;
    private Camera mCamera;
    private PreviewCallback mPreviewCallback;
    private AutoFocusCallback mAutoFocusCallback;

    public BarcodePreview(final Activity activity, final Camera camera, final PreviewCallback previewCallback, final AutoFocusCallback autoFocusCallback) throws Exception {
        super(activity);

        mActivity = activity;
        mCamera = camera;
        mPreviewCallback = previewCallback;
        mAutoFocusCallback = autoFocusCallback;

        mSurfaceHolder = getHolder();
        if (mSurfaceHolder == null) {
            // ...
        }

        mSurfaceHolder.addCallback(this);
    }

    @Override
    public void surfaceCreated(final SurfaceHolder surfaceHolder) {
        try {
            mCamera.setPreviewDisplay(surfaceHolder);
        }
        catch (Exception e) {
            // ...
        }
    }

    @Override
    public void surfaceDestroyed(final SurfaceHolder surfaceHolder) {
            // ...
    }

    @Override
    public void surfaceChanged(final SurfaceHolder surfaceHolder, final int format, final int width, final int height) {
        if (mSurfaceHolder.getSurface() == null) {
            // ...
            return ;
        }

        try {
            mCamera.stopPreview();
            // ...
            mCamera.setPreviewDisplay(mSurfaceHolder);
            mCamera.setPreviewCallback(mPreviewCallback);
            mCamera.startPreview();
            mCamera.autoFocus(mAutoFocusCallback);
        }
        catch (Exception e) {
            // ...
        }
    }
}
Was it helpful?

Solution

As I pointed out, this error seems to only occurs on the Moto X and seems to be specific to some use-cases.

It just happens from time to time on this device running Android 4.4.2.

To me, it's just a specific/too-localized bug.

Closed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top