camera1-to-camerax

Migrate legacy Android Camera1 and Camera2 code to CameraX with ProcessCameraProvider.

Updated May 22, 2026
One-click install
npx skills add https://github.com/ekawijayasusilo/kmp_template --skill camera1-to-camerax-ekawijayasusilo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: camera1-to-camerax
Source: https://github.com/ekawijayasusilo/kmp_template/tree/main/.claude/skills/camera1-to-camerax
Command: npx skills add https://github.com/ekawijayasusilo/kmp_template --skill camera1-to-camerax-ekawijayasusilo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Legacy Android camera implementations often suffer from device-specific rotation bugs and require complex lifecycle code, making photo preview and capture unreliable.

Core Features & Use Cases

  • CameraX dependency setup: Add the correct CameraX libraries (including Camera Compose) to enable Preview and ImageCapture in a modern way.
  • Lifecycle-bound camera initialization: Bind Camera1/Camera2 logic to a LifecycleOwner via ProcessCameraProvider instead of manually opening/closing the camera.
  • Preview, tap-to-focus, and photo capture: Implement a CameraX preview with tap-to-focus (Views or Compose) and capture photos using ImageCapture while ensuring proper ImageProxy handling.

Quick Start

Use the camera1-to-camerax skill to migrate your existing Camera1 or raw Camera2 Android camera code so it uses ProcessCameraProvider, Preview, and ImageCapture with tap-to-focus.

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 legacy Camera1 code to CameraX in Android?

Migrate legacy Camera1 code to CameraX by adding CameraX dependencies, binding use cases via ProcessCameraProvider to a LifecycleOwner, and replacing manual camera lifecycle handling with Preview and ImageCapture.

How does CameraX ProcessCameraProvider handle lifecycle management?

ProcessCameraProvider handles lifecycle management by binding camera use cases directly to a LifecycleOwner, eliminating the need to manually open and close the camera hardware during Android lifecycle events.

Can I use CameraX with Jetpack Compose for preview and photo capture?

Yes, you can use CameraX with Jetpack Compose by adding the Camera Compose dependency, implementing a PreviewView, and binding ImageCapture use cases to the Compose lifecycle owner for photo capture.

What is the best way to implement tap-to-focus when migrating to CameraX?

The best way to implement tap-to-focus in CameraX is by configuring the CameraControl focus metering behavior on top of the Preview use case, avoiding manual focus matrices used in older Camera1 implementations.

Why does my CameraX ImageCapture return incorrect rotation on some devices?

CameraX ImageCapture handles device-specific rotation automatically when properly bound to a LifecycleOwner via ProcessCameraProvider, resolving unreliable orientation bugs common in legacy Camera1 and raw Camera2 custom code.