camera1-to-camerax

Migrate legacy Camera1 and Camera2 code to lifecycle-aware CameraX.

1|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/premex-ab/claude-marketplace --skill camera1-to-camerax
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: camera1-to-camerax
Source: https://github.com/premex-ab/claude-marketplace/tree/main/plugins/android-camera1-to-camerax/skills/camera1-to-camerax
Command: npx skills add https://github.com/premex-ab/claude-marketplace --skill camera1-to-camerax

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the pain of migrating legacy Android camera code (Camera1 and raw Camera2 usage) that suffers from lifecycle fragility, rotation bugs, and device-specific dependency headaches.

Core Features & Use Cases

  • CameraX dependency setup: Add compatible CameraX libraries (including interoperability requirements for specific Compose extensions).
  • Lifecycle-aware camera binding: Replace manual camera open/close and custom lifecycle code with ProcessCameraProvider and bind use cases to a LifecycleOwner.
  • Preview, tap-to-focus, and capture: Implement Preview and ImageCapture with correct focus metering and safe ImageProxy handling.

Use it when modernizing an existing app that currently uses SurfaceView/SurfaceHolder callbacks, manual orientation matrices, and onResume/onPause camera management, but needs a CameraX-based implementation with Compose or Views.

Quick Start

Ask an AI to rewrite your current Camera1/Camera2 camera preview, focus, and photo-capture code into a CameraX implementation that binds to a LifecycleOwner, uses ProcessCameraProvider, supports tap-to-focus, and correctly closes ImageProxy.

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

To migrate Camera1 to CameraX, replace manual camera open/close logic and orientation matrices with ProcessCameraProvider, binding Preview and ImageCapture use cases directly to a LifecycleOwner for lifecycle-aware execution.

Why does my Android camera preview break on rotation and lifecycle changes?

Legacy Camera1 implementations suffer from lifecycle fragility and rotation bugs due to manual onResume/onPause camera management. Binding CameraX use cases to a LifecycleOwner resolves these device-specific orientation and lifecycle issues automatically.

How do I implement tap-to-focus with CameraX in Jetpack Compose?

Implement tap-to-focus in Jetpack Compose by configuring CameraX focus metering within your Preview use case, ensuring you add the required Compose interoperability dependencies for correct CameraX extension support.

Does CameraX support both Views and Jetpack Compose for camera preview?

Yes, CameraX supports both Views and Jetpack Compose scenarios. You must add compatible CameraX libraries, including specific Compose interop extensions, to successfully bind Preview and ImageCapture workflows across both UI toolkits.

What is the best way to handle ImageProxy capture callbacks in CameraX?

The correct way to handle ImageProxy in CameraX capture callbacks is to safely close the ImageProxy object after processing. This prevents image buffer leaks when executing your ImageCapture workflows.

Can I remove manual orientation matrices when upgrading to CameraX?

Yes, you can remove manual orientation matrices when upgrading to CameraX. The CameraX stack handles rotation correctly internally, eliminating the need for custom orientation logic previously required by Camera1 or raw Camera2 APIs.