android-camera-bugfix-skill

Diagnose and fix Android Camera2 and CameraX failures across open, preview, capture, and lifecycle flows.

1|Updated Jun 27, 2026
One-click install
npx skills add https://github.com/TE-QuanBZhang/skills-pool --skill android-camera-bugfix-skill-te-quanbzhang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: android-camera-bugfix-skill
Source: https://github.com/TE-QuanBZhang/skills-pool/tree/main/ai-coding/skills/android-camera-bugfix-skill
Command: npx skills add https://github.com/TE-QuanBZhang/skills-pool --skill android-camera-bugfix-skill-te-quanbzhang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Android camera bugs — black previews, failed captures, frozen camera switches, and device-specific HAL crashes — are hard to root-cause because they span permissions, Surface lifecycles, capture session state machines, and hardware capabilities. This Skill provides a structured triage and repair workflow for Camera2 and CameraX issues. ## Core Features & Use Cases - Symptom-based triage: Classifies failures into open failures, black/green preview, capture failure, front/rear switching, flash/focus/exposure, and device compatibility, each with targeted log keywords and API checkpoints. - Full-chain diagnosis: Walks the pipeline from permission grant through openCamera, session creation, setRepeatingRequest, and ImageReader callbacks, with adb logcat and dumpsys commands for evidence collection. - Fix patterns and guardrails: Provides ordered repair sequences (stop/abort/close/reopen), ImageReader buffer-leak fixes, CameraX bind/unbind rules, heuristics, anti-patterns, and a verification checklist across devices and Android versions. - Use Case: A user reports the preview goes black after switching from rear to front camera. The Skill guides checking that the old CaptureSession and CameraDevice were closed before reopening, then verifies the fix across rotation and background/foreground transitions. ## Quick Start Ask the agent to diagnose why the Android camera preview is black after switching cameras and propose a fix with verification steps.

Frequently Asked Questions about android-camera-bugfix-skill

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

FAQPage Schema
How do I fix a black camera preview on Android?

Black preview usually means the Surface was never attached to the CaptureSession or setRepeatingRequest was called before onConfigured. Check TextureView/SurfaceView/PreviewView lifecycle timing and confirm the session reached its configured state before submitting requests.

Why does Android camera capture hang or never return?

Capture hangs typically occur when an ImageReader has all maxImages buffers acquired and none closed, filling the buffer pool. Ensure every onImageAvailable path, including error and early-return branches, calls image.close().

Camera2 vs CameraX — which should I debug differently?

Camera2 debugging focuses on CameraDevice/CameraCaptureSession state callbacks, HandlerThread cleanup, and manual resource pairing. CameraX debugging centers on bindToLifecycle/unbindAll ordering, correct LifecycleOwner usage, and closing ImageAnalysis images.

Why does the camera freeze when switching front and rear cameras?

Switch freezes happen when the old CaptureSession or CameraDevice was not closed before opening the new one, or session creation raced the old close. Follow the ordered sequence: stopRepeating, abortCaptures, close session, close device, then reopen and rebind.

Why does the camera work on Pixel but fail on Samsung or Xiaomi devices?

Device HAL differences cause OEM-specific failures. Query CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL and degrade gracefully for LIMITED or LEGACY devices, and always re-query capabilities per cameraId rather than assuming rear-camera features apply to front.

What are the limitations of this camera debugging approach?

CodeGraph does not index XML layouts, AndroidManifest.xml, or Gradle files, so permission and dependency issues need manual grep-based checks. HAL-level crashes like tombstones require vendor escalation; the app side can only add defensive close and retry logic.