Compile error while setting imageAnalysis.setAnalyzer()

I was also facing the same issue today, so , found that there is one missing parameter which is Executor which we need to pass otherwise same compilation error comes.

As as I worked with AsyncTasks in my past, I recognized that for doing tasks in multiple threads in AsyncTasks, we need to use its static method executeOnExecutor() which takes an Executor as its parameter, so I used the same parameter i.e. I used AsyncTask.THREAD_POOL_EXECUTOR as first parameter in setAnalyser() method. And it worked like a charm!! After putting this as first parameter you need to perform some minor changes in your previous code.

Like this

 imageAnalysis.setAnalyzer(AsyncTask.THREAD_POOL_EXECUTOR,
 object : ImageAnalysis.Analyzer {    // changes to be done in this line
                    override fun analyze(imageProxy: ImageProxy, rotationDegrees: Int) {
                        val image = FirebaseVisionImage.fromMediaImage(
                                imageProxy.image!!, getFirebaseRotation(rotationDegrees)
                        )
        
                        if (processingBarcode.get() ||
                                !lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
                            return
                        }
    ..................
    .............
    .......BLA BLA BLA
    }

Try it and tell me if this approach works with your use case.

EDIT

If you don't like AsyncTask, then I have found an alternative for getting an Executor instance without using AsyncTask.THREAD_POOL_EXECUTOR.

You can use Executors.newFixedThreadPool(n), to get an Executor instance. Here, n stands for the number of threads you want to create in the thread pool.It varies depending upon your use-case.

Tell me if it worked for you.