Android camera2: java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more

LittleFunny picture LittleFunny · Sep 12, 2015 · Viewed 9.5k times · Source

Hello having trouble to fix this issue.

I already have a imageReader.close called inside the ImageAvailable callback but still having the error:

java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more.

Code I have is here:

private ImageReader.OnImageAvailableListener imageAvailableListener = new ImageReader.OnImageAvailableListener()
{
    @Override
    public void onImageAvailable(ImageReader reader) {
        Image img = mReader.acquireLatestImage();

        mReader.close();
    }

};

ps. I also use the argument reader as well but not seem to solve the problem

Answer

LittleFunny picture LittleFunny · Sep 12, 2015

Ok I have solved my problem. I need to close the img object not the ImageReader.