Camerax Analyzer ImageProxy - Image Already Closed

Solution 1:

It seems like the logic you're trying to accomplish looks like this.

fun analyze(imageProxy) {
    if (isAnalyzing) {
        imageProxy.close() // 1
    } else {
        val image = imageInput.fromMediaImage(...)
        objectDetector.process(image)
                    .addOnSuccessListener(OnSuccessListener { result ->
                        // Do something with the result
                        imageProxy.close() // 2
                        isAnalyzing.set(false)
                    })
                    .addOnFailureListener(OnFailureListener { exception ->
                        // Do something with the exception
                        imageProxy.close() // 3
                        isAnalyzing.set(false)
                    })
    }
}

I might be wrong, but it looks like you're doing 1, but not 2 and 3. Could you update your code to follow this pattern and see if you're still encountering the issue.