https://developer.android.com/agents/skills/camera/camera1-to-camerax/skill

Community

Migrate Camera to CameraX safely

Authorfornewid
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Camera1 implementations are complex, tied to manual lifecycle handling, and often require brittle orientation and focus logic. This migration guide helps you replace those legacy camera APIs with CameraX components that integrate cleanly with Android lifecycles.

Core Features & Use Cases

  • Dependency setup for CameraX: Adds CameraX libraries using a Version Catalog or direct Gradle dependencies, with guidance to use minimum versions for interoperability and Compose extensions.
  • Lifecycle-safe camera initialization: Uses ProcessCameraProvider to bind Preview and ImageCapture to a LifecycleOwner instead of manually opening/closing the camera in onResume/onPause.
  • Preview and tap-to-focus: Supports both View-based (PreviewView + startFocusAndMetering) and Compose-based (CameraXViewfinder + metering via coordinate transforms) tap-to-focus patterns.
  • Photo capture and rotation handling: Captures via ImageCapture.takePicture, processes ImageProxy rotation degrees, mirrors the front camera output, and ensures image.close() is called.
  • Switching cameras: Reconfigures CameraSelector (front/back) and re-runs the binding flow.

Quick Start

Ask the AI to migrate my existing Android android.hardware.Camera + SurfaceView code to CameraX with ProcessCameraProvider, Preview, ImageCapture, and tap-to-focus for my UI toolkit (Views or Compose), then provide the exact Kotlin snippets and constraints to follow.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: https://developer.android.com/agents/skills/camera/camera1-to-camerax/skill
Download link: https://github.com/fornewid/android-developers-changelog/archive/main.zip#https-developer-android-com-agents-skills-camera-camera1-to-camerax-skill

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.