camerax
できること
このスキルは、CameraXライブラリを使ってAndroidアプリにカメラ機能を作るための指針とパターンを提供します。写真、動画、エフェクトをアプリに加えるAndroid開発者向けです。
使う場面
- ✓Androidアプリに、カメラや動画の録画の画面を追加したいとき。
- ✓古いAndroidのカメラのコードをCameraXに移行する必要があるとき。
- ✓カメラのフィードにML KitまたはMedia3のエフェクトを加えたいとき。
スキルのリンク
https://github.com/android/skills/blob/main/camera/camerax/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“CameraXを使って、Androidアプリに音声付きの動画録画を追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、CameraXライブラリの手順ごとのパターンを示します。設定を反映させるために、戻り値を保存し直す必要があるビルダーのメソッドを指摘し、ハードウェアの連携とエフェクトの統合を扱います。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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.
Core workflows
Handling immutable API patterns
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)
}
<br />
See immutability for a list of affected classes.
Migrating to CameraX
When migrating legacy camera codebases to the CameraX Jetpack library:
- Camera1 to CameraX : For migrating legacy
android.hardware.Cameraimplementations, surface handling, and manual lifecycles, see the Camera1 migration guide. - Camera2 to CameraX : For migrating more recent but verbose
android.hardware.camera2implementations, session state callbacks, and interop patterns, see the Camera2 migration guide.
Comprehensive feature blueprinting
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:
- Manual controls : Break down into the
ViewModelstate, the controller layer, and theCamera2Interopwiring in the session. - RAW capture: Separate JPEG and RAW output configurations into discrete build steps.
- Custom effects : Prefer
Media3EffectorSurfaceProcessorover manual OpenGL pipelines unless absolute performance is required. - Low-light : See low-light for Night Mode and LLB guidance.
- Foldables : See foldables for handling dynamic postures and hinge states.
- XR, AR, and VR : See xr for spatial tracking, passthrough synchronization, and latency guardrails.
- Thermals and power : See thermals for managing
StreamUseCaseoptimizations andPowerManagerthermal states. - Testing and mocking : See testing for using
FakeCameraConfig, handling asynchronous lifecycles, and validating analysis pipelines. - ML Kit spatial analysis : See mlkit-spatial for coordinate mapping, rotation logic, and mirrored lens handling.
- Wear OS camera remote : See wear-os for circular UI constraints, Data Layer API syncing, and remote trigger logic.
See expert-blueprints for step-by-step guides.
API discovery
Always use higher-level abstractions instead of low-level manual wiring:
- Analysis : Use
MlKitAnalyzerinstead of manualImageAnalysis.Analyzer. - Filters and effects : Use
Media3Effectfor standard post-processing. - Multi-camera : Use
ConcurrentCameraAPIs for dual-stream setups.
See modern-apis for current recommendations.
Code quality and architectural rules
Adhere to the following Android ecosystem standard patterns when building your camera implementations:
- Testing, fakes over mocks : Avoid mocking libraries like
Mockito, especially for multi-step CameraX interfaces likeImageProxy. Build "Fakes" to verify state rather than unreliable implementation details. - Google Truth assertions : Use
assertThatover standardJUnitassertions likeassertEqualsfor improved readability. - Explicit test runners : Always define an explicit
@RunWithfor test classes to ensure the CI environment executes them correctly. - Semantic UI merging : When building custom camera controls in Compose, such as a button with an
IconandText, use `semantics {
よくある質問
なぜ音声の設定が無視されるのですか?
CameraXの一部のビルダーのメソッドは新しいオブジェクトを返すため、その結果を保存し直す必要があります。このスキルがそれを指摘します。
古いCamera APIからの移行も手伝えますか?
はい。古いCameraのコードをCameraXに移行するための指針があります。
ML Kitも扱いますか?
はい。CameraXの設定にML KitやMedia3のエフェクトを加える方法を扱います。
詳細
作者による元の説明
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.
repo: android/skills
人気
- GitHubのスター
- 10k
- ランキング
- #11908
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/29
コメント
- …
このリポジトリの他のスキル
agp-9-upgrade
10kエージェントが、AndroidアプリをAndroid Gradle Plugin 9にアップグレードし、その破壊的変更に対応できるよう支援します。マルチプラットフォームのプロジェクトは対象外です。
android-for-cars-parked-apps
10kエージェントが、Androidの動画、ゲーム、ブラウザのアプリを、Android AutoとAndroid Automotiveで駐車中のアプリとして動かせるように適合させるよう支援します。
appfunctions
10kエージェントが、Androidアプリの主要な作業の流れを見つけ、AIエージェントや音声コマンドが実行できるAppFunctionsとして公開できるよう支援します。
litert-lm
10kエージェントが、LiteRT-LMのKotlin APIを使って、端末上でオープンなテキストAIモデルを動かすAndroidアプリを作れるよう支援します。
似ているスキル
android-clean-architecture
280kエージェントがAndroidプロジェクトを効率よく整理できるようにします。コードを構造化して、保守や新機能の開発をしやすくします。
compose-multiplatform-patterns
280kエージェントがKMPプロジェクトでCompose MultiplatformとJetpack Composeのパターンを使えるようにします。状態管理、ナビゲーション、テーマ設定、パフォーマンスを扱います。
dart-flutter-patterns
280kエージェントがDartとFlutterのアプリ向けのコードを書けるようにします。最新のパターンを使い、堅牢で管理しやすいアプリを作ります。