i'm use camerax 1.3.2 (kotlin) when run application screen not show preview

Skip to first unread message


Mar 27, 2024, 9:23:55 PMMar 27
to Android CameraX Discussion Group
private fun startCamera() {
val cameraProviderFuture = ProcessCameraProvider.getInstance(this)
val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()

val preview = Preview.Builder().build().also {

val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

videoCapture = VideoCapture.withOutput(Recorder.Builder()

try {

this, cameraSelector, preview, videoCapture

} catch (e: Exception) {
Log.e("VideoCaptureActivity", "Use case binding failed", e)
}, ContextCompat.getMainExecutor(this))

Charcoal Chen

Mar 27, 2024, 10:34:12 PMMar 27
to pisalboy, Android CameraX Discussion Group

Could you provide some info to clarify the issue? Thanks.

1. Does this issue happen on a specific device or all devices?
2. If this only happens on a specific device, could you provide the device info?
3. Is there any exception thrown when invoking the "bindToLifecycle" method?
4. Do you grant CAMERA permission to the app?
5. Can the preview work correctly if only binding Preview?

You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/e03a65ad-bba3-48c2-a4ad-00f3e80c375fn%40android.com.


Mar 28, 2024, 12:32:02 AMMar 28
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, pisalboy
i'm sorry 

 Run on Pixel 6a (android 14) and redmi note 10 pro (android 13)
 Yes i'm    grant CAMERA permission , Record Audio , Write External storage

Thank you so much 
ในวันที่ วันพฤหัสบดีที่ 28 มีนาคม ค.ศ. 2024 เวลา 9 นาฬิกา 34 นาที 12 วินาที UTC+7 charco...@google.com เขียนว่า:

Charcoal Chen

Mar 28, 2024, 3:20:18 AMMar 28
to pisalboy, Android CameraX Discussion Group

I tried your code in the CameraXBasic sample app. The preview can work well on the Pixel 6a device. What I did are: 
- Change the build.gradle to use CameraX 1.3.2 (some dependencies conflicts might need to be resolved also: compileSdk,  java_version, kotlin_version)
- Replace CameraXFragment#bindCameraUseCases() implementation with the code you provided (resolve some conflicts like "this" to "requireContext()")

Looks like the problem is not in the code provided by you. If possible, maybe you can create an issue here and provide a minimal sample project code which can reproduce the issue. Then, I can try to check what is the root cause.


Mar 28, 2024, 5:12:27 AMMar 28
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, pisalboy
Hi  Thank you so much. I've solved the problem already.

ในวันที่ วันพฤหัสบดีที่ 28 มีนาคม ค.ศ. 2024 เวลา 14 นาฬิกา 20 นาที 18 วินาที UTC+7 charco...@google.com เขียนว่า:
Reply all
Reply to author
0 new messages