camera1-to-camerax

Migrates legacy Android Camera1 and Camera2 implementations to the CameraX Jetpack library.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/kariemSeiam/android-claw --skill camera1-to-camerax-kariemseiam
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: camera1-to-camerax
Source: https://github.com/kariemSeiam/android-claw/tree/main/skills/installed/camera-camera1-to-camerax
Command: npx skills add https://github.com/kariemSeiam/android-claw --skill camera1-to-camerax-kariemseiam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy Android camera code built on Camera1 or raw Camera2 APIs is verbose, error-prone, and riddled with device-specific rotation and lifecycle bugs. This Skill provides a step-by-step playbook to migrate that code to CameraX, the lifecycle-aware Jetpack library that handles rotation, focus metering, and device compatibility automatically. ## Core Features & Use Cases - Dependency Setup: Adds the correct CameraX artifacts (core, camera2, lifecycle, view, compose) via Version Catalog or plain Gradle coordinates. - Lifecycle-Aware Migration: Replaces manual camera open/close logic with ProcessCameraProvider binding to a LifecycleOwner. - Dual UI Toolkit Support: Provides separate implementation paths for Android Views (PreviewView) and Jetpack Compose (CameraXViewfinder), including tap-to-focus and photo capture with correct rotation handling. - Use Case: An app with a legacy SurfaceView-based camera screen that breaks on rotation can be migrated step by step: remove Camera1 code, bind Preview and ImageCapture use cases, and capture correctly rotated photos with a few dozen lines of Kotlin. ## Quick Start Migrate my Android app's legacy Camera1 camera screen to CameraX with a Compose viewfinder and tap-to-focus support.

Frequently Asked Questions about camera1-to-camerax

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from Camera1 to CameraX in Android?▼

Remove all android.hardware.Camera instances and SurfaceHolder callbacks, add the androidx.camera dependencies, then bind Preview and ImageCapture use cases to a LifecycleOwner through ProcessCameraProvider. CameraX handles lifecycle and rotation automatically.

How to show a CameraX preview in Jetpack Compose?▼

Use CameraXViewfinder from the camera-compose artifact with a SurfaceRequest state provided by Preview's surface provider. Avoid wrapping PreviewView in an AndroidView, which causes resizing issues.

What minimum CameraX version is needed for Compose support?▼

Use CameraX 1.3.0 or higher for general interoperability, or 1.5.0 or higher to access the Compose extensions such as CameraXViewfinder from the camera-compose artifact.

Why does my CameraX capture pipeline freeze after taking a photo?▼

The ImageProxy was not closed in the capture callback. Always call image.close() after reading the buffer in onCaptureSuccess, otherwise the capture pipeline locks and subsequent photos fail.

Does CameraX handle camera rotation and orientation automatically?▼

Yes. ImageProxy exposes rotationDegrees for correcting captured bitmaps, and MeteringPointFactory handles focus coordinate transforms. For Compose, update targetRotation on Preview and ImageCapture when the display rotation changes.