brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
cameraxProvide technical guidance for Android camera development with CameraX. Use when implementing camera features, handling asynchronous recording lifecycles, wiring low-level hardware interop using CameraX, or integrating ML Kit or Media3 effects.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: camerax description: Provide technical guidance for Android camera development with CameraX. Use when implementing camera features, handling asynchronous recording lifecycles, wiring low-level hardware interop using CameraX, or integrating ML Kit or Media3 effects. license: Complete terms in LICENSE.txt metadata: author: Google LLC last-updated: '2026-09-24' keywords:
This skill provides procedural guidance and standard patterns for building
camera applications on Android, with a focus on CameraX, including its
Camera2Interop utilities, and Media3 integrations.
Various Android camera and media APIs, especially CameraX VideoCapture, use a
fluent, immutable builder-like pattern where methods return a new instance.
Failing to reassign these results in settings, such as audio, being ignored.
Pattern: Reassignment is required
// WRONG
run {
val pending = recorder.prepareRecording(context, opts)
pending.withAudioEnabled() // This returns a new instance which is ignored
val active = pending.start(exec, listener)
}
// CORRECT
run {
val pending = recorder.prepareRecording(context, opts)
.withAudioEnabled() // Chaining works
val active = pending.start(exec, listener)
}
// ALSO CORRECT
run {
var pending = recorder.prepareRecording(context, opts)
pending = pending.withAudioEnabled() // Reassignment
val active = pending.start(exec, listener)
}
See immutability for a list of affected classes.
When migrating legacy camera codebases to the CameraX Jetpack library:
android.hardware.Camera implementations, surface handling, and manual lifecycles, see the Camera1 migration guide.android.hardware.camera2 implementations, session state callbacks, and interop patterns, see the Camera2 migration guide.For multi-step features that involve multiple files and hardware-level wiring, follow the Structural Blueprinting approach to avoid system timeouts. Such complex features include:
ViewModel state, the controller layer, and the Camera2Interop wiring in the session.Media3Effect or SurfaceProcessor over manual OpenGL pipelines unless absolute performance is required.StreamUseCase optimizations and PowerManager thermal states.FakeCameraConfig, handling asynchronous lifecycles, and validating analysis pipelines.See expert-blueprints for step-by-step guides.
Always use higher-level abstractions instead of low-level manual wiring:
MlKitAnalyzer instead of manual ImageAnalysis.Analyzer.Media3Effect for standard post-processing.ConcurrentCamera APIs for dual-stream setups.See modern-apis for current recommendations.
Adhere to the following Android ecosystem standard patterns when building your camera implementations:
Mockito, especially for multi-step CameraX interfaces like ImageProxy. Build "Fakes" to verify state rather than unreliable implementation details.assertThat over standard JUnit assertions like assertEquals for improved readability.@RunWith for test classes to ensure the CI environment executes them correctly.Icon and Text, use semantics { mergeDescendants = true } to ensure screen readers announce them as a single, coherent unit.Camera apps run on a wide variety of hardware, from mobile phones and foldables to tablets, laptops, and even smart appliances. Have consideration for the specific hardware the app is running on.
isRecording state before attempting to stop or pause. Handle VideoRecordEvent.Start for UI state updates, not just the initial call.CAMERA permission; check for RECORD_AUDIO specifically when enabling audio in VideoCapture.