I am unable to add the library for the Builder class, I am pressing Alt + Enter to import but nothing works. I’ve also tried importing it manually "androidx.test.runner:runner:1.5.2@aar" but it doesn’t stick, tried restarting android studio. Here is the Documentation I’m following: https://developer.android.com/media/camera/camerax/preview
fun bindPreview(cameraProvider : ProcessCameraProvider) {
var preview : Preview = Preview.Builder()
.build()
var cameraSelector : CameraSelector = CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_BACK)
.build()
preview.setSurfaceProvider(previewView.getSurfaceProvider())
var camera = cameraProvider.bindToLifecycle(this as LifecycleOwner, cameraSelector, preview)
}
2
Answers
The gradle is a tool for managing the dependencies, in your case, you can run the gradle build command manually, and check the running log, it will show the detailed info about why the dependency is not downloaded and imported.
the command is like this, with debugging log enabled:
This means your cameraX library did not load in your project. If your android studio is old you must use Jcenter() in gradle allrepo. When you see camerax library download in your project after that import that code.