camerax

Implement Android camera features with CameraX, Camera2Interop, ML Kit, and Media3.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill camerax-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: camerax
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/pi/.pi/agent/skills/camerax
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill camerax-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building Android camera features involves verbose Camera2 boilerplate, immutable API pitfalls, asynchronous recording lifecycles, and hardware diversity across phones, foldables, Wear OS, and XR devices. This Skill provides proven patterns and migration guides that prevent common failures like blocked capture pipelines, ignored audio settings, and coordinate mapping bugs. ## Core Features & Use Cases - Migration Guides: Step-by-step paths for moving legacy Camera1 and Camera2 codebases to CameraX with ProcessCameraProvider, PreviewView, and CameraXViewfinder. - Feature Blueprints: Phased implementation plans for manual controls (ISO, exposure, focus via Camera2Interop), RAW capture, low-light modes, and Media3 effects. - Specialized Hardware Guidance: Dedicated references for foldables, Wear OS remote viewfinders, XR passthrough, thermal management, and ML Kit spatial coordinate mapping. - Use Case: When a user asks to add tap-to-focus in a Jetpack Compose camera screen, the Skill supplies the CameraXViewfinder and SurfaceOrientedMeteringPointFactory pattern with correct rotation handling. ## Quick Start Ask the agent to help implement a CameraX photo capture flow in Jetpack Compose with tap-to-focus and front-camera mirroring.

Frequently Asked Questions about camerax

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

FAQPage Schema
How do I migrate from Camera2 to CameraX?

Replace CameraDevice and CameraCaptureSession callbacks with ProcessCameraProvider bound to a LifecycleOwner, and swap ImageReader flows for ImageCapture and ImageAnalysis use cases. Use Camera2Interop.Extender when you still need specific CaptureRequest options like CONTROL_AE_MODE.

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

Use CameraXViewfinder with a SurfaceRequest and CoordinateTransformer to map tap offsets, then create a metering point with SurfaceOrientedMeteringPointFactory and call cameraControl.startFocusAndMetering. Avoid wrapping PreviewView in an AndroidView, which causes resizing issues.

Why is audio missing from my CameraX video recording?

PendingRecording.withAudioEnabled returns a new instance rather than mutating the existing one, so ignoring the return value silently drops audio. Chain the call or reassign the variable before calling start, and verify RECORD_AUDIO permission is granted.

Should I use ImageAnalysis.Analyzer or MlKitAnalyzer for ML features?

Prefer MlKitAnalyzer from the camera-mlkit-vision artifact, which automates coordinate mapping and multi-format support over manual ImageAnalysis.Analyzer implementations. Always close each ImageProxy and use STRATEGY_KEEP_ONLY_LATEST to avoid queuing stale frames.

Does CameraX support foldable devices and posture changes?

Yes, combine Jetpack WindowManager FoldingFeature detection with ViewPort updates so tap-to-focus and capture coordinates stay accurate across tabletop and book postures. Avoid spanning the preview across the hinge and prefer PreviewView scaling over rebinding use cases during fold events.

Why do my CameraX tests fail or flake on CI?

Camera tests often fail because virtual camera initialization is slow or asynchronous lifecycles are not awaited. Use fakes instead of Mockito, Google Truth assertions, explicit RunWith annotations, IdlingResource or CountDownLatch for binding, and GrantPermissionRule to bypass permission dialogs.