Skip to content

Add Camera2 to CameraX migration snippets#943

Open
madebymozart wants to merge 5 commits into
mainfrom
madebymozart/camera2-camerax-migration-snippets
Open

Add Camera2 to CameraX migration snippets#943
madebymozart wants to merge 5 commits into
mainfrom
madebymozart/camera2-camerax-migration-snippets

Conversation

@madebymozart

Copy link
Copy Markdown
Contributor

Added Camera2 to CameraX Snippets for migration

@madebymozart madebymozart requested a review from donovanfm June 8, 2026 14:52
@madebymozart madebymozart self-assigned this Jun 8, 2026
@snippet-bot

snippet-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 8 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread camerax/src/main/java/com/example/camerax/snippets/Camera2ToCameraXSnippets.kt Outdated
*   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`.
Comment thread gradle/libs.versions.toml Outdated
Comment thread gradle/libs.versions.toml Outdated
madebymozart and others added 3 commits June 9, 2026 16:55
Change resource name

Co-authored-by: Yacine Rezgui <rezgui.y@gmail.com>
change resource name

Co-authored-by: Yacine Rezgui <rezgui.y@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants