Add Camera2 to CameraX migration snippets#943
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Camera2 to CameraX migration snippets, covering initialization, previewing, capturing, image analysis, and interop, along with build configuration snippets. The review feedback highlights critical improvements: handling potential null values from BitmapFactory.decodeByteArray to prevent a NullPointerException, wrapping image analysis in a try-finally block to guarantee imageProxy.close() is called even if an exception occurs, and correcting comment syntax in the TOML dependency snippet from // to #.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
* Add `androidx.camera:camera-camera2` to `libs.versions.toml` and `camerax/build.gradle.kts`.
* Refactor `Camera2ToCameraXSnippets.kt`:
* Remove unused imports.
* Add null check for `BitmapFactory.decodeByteArray` result.
* Wrap `ImageAnalysis` analyzer logic in a `try-finally` block to guarantee `imageProxy.close()`.
* Update `@OptIn` to `@ExperimentalCamera2Interop`.
Change resource name Co-authored-by: Yacine Rezgui <rezgui.y@gmail.com>
change resource name Co-authored-by: Yacine Rezgui <rezgui.y@gmail.com>
Added Camera2 to CameraX Snippets for migration