Overlay creation fails when starting camera preview
<p>I'm trying to draw the camera preview onto a SurfaceHolder with this code:</p>

<pre><code>    @Override
    public void onCreate(SurfaceHolder surfaceHolder) {
        super.onCreate(surfaceHolder);

        Log.d(TAG, "Releasing camera first, just to make sure");
        releaseCamera();

        Log.d(TAG, "Opening Camera object.");
        mCamera = Camera.open();

        if (mCamera == null) {
            Log.d(TAG, "Camera is null.");
        }
    }

    @Override
    public void onSurfaceCreated(SurfaceHolder holder) {
        super.onSurfaceCreated(holder);
        Log.d(TAG, "Surface created.");

        try {
            if (holder == null) {
                Log.d(TAG, "SurfaceHolder is empty.");
            }

            Log.d(TAG, "Setting preview display.");
            mCamera.setPreviewDisplay(holder);

        } catch (IOException e) {
            Log.d(TAG, "IOException on setPreviewDisplay.");

            releaseCamera();
        }
    }


  @Override
    public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        super.onSurfaceChanged(holder, format, width, height);
        Log.d(TAG, "Surface changed.");

        Log.d(TAG, "Starting preview.");
        mCamera.startPreview();
    }
</code></pre>

<p>However, when I run the app, either on the emulator or my actual phone, I get the error "Overlay create failed - retrying" multiple times, followed by "Overlay Creation Failed!". I then get a RuntimeException, stating that "startPreview failed".</p>

<p>I've read through the sample code, as well as a lot of the related questions here, but no luck. I have also checked the permissions, which I think are correct.
Any ideas?</p>

<p>Thanks in advance.</p>
