I'm getting errors when I use sample code from
import androidx.appcompat.app.AppCompatActivity
class X: AppCompatActivity(), CameraXConfig.Provider { ...
fun everythingInThisFunctionIsOfficalSampleCodeItShouldLikeTotallyWork(cameraProvider : ProcessCameraProvider) {
var cameraSelector : CameraSelector = CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_BACK)
.build()
val preview = Preview.Builder().build()
preview.setPreviewSurfaceProvider {
resolution, surfaceReleaseFuture ->
// Create the SurfaceTexture with the required resolution
val surfaceTexture = android.graphics.SurfaceTexture(0)
surfaceTexture.setDefaultBufferSize(resolution.width, resolution.height)
val surface = Surface(surfaceTexture)
// Once surfaceReleaseFuture completes, the Surface and SurfaceTexture
// are no longer used by the camera hence safe to close.
surfaceReleaseFuture.addListener(
Runnable {
surface.release()
surfaceTexture.release()
}, ContextCompat.getMainExecutor(this))
// Return the Surface back in a ListenableFuture
Futures.immediateFuture(surface)
}
cameraProvider.bindToLifecycle(this, cameraSelector, preview)
} ...
}
ERROR
Futures.immediateFuture can only be called from within the same library group (groupid=androidx.camera)
The Futures class was imported, by Android Studio's suggestions, from
import androidx.camera.core.impl.utils.futures.Futures
As for the versions...
def camerax_version = "1.0.0-alpha09"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
// If you want to use the CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha06"
// If you want to use the CameraX Extensions library
implementation "androidx.camera:camera-extensions:1.0.0-alpha06"
// If you want to use the CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:1.0.0-alpha03"
Thanks for the help
Stuart
ps. It would sure be nice if the published example code had fully qualified names. All sorts of mistakes seem to result when they don't.