跳到正文
cccskills
免费在 GitHub 公开

android

Provides expert knowledge for building modern native Android apps using Kotlin, Jetpack Compose, Material Design 3, MVI architecture, Hilt dependency injection, and Media3/ExoPlayer.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md5.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Android + Kotlin (Jetpack Compose & Media3)

This playbook defines the architecture, UI design system, performance guidelines, and testing strategy for native Android applications.

android-ui-design owns specialized Jetpack Compose phone UI/UX design, implementation, review, and audit guidance. This skill remains the general guide for architecture, Hilt dependency injection, Media3, performance, and testing.


1. Lead Architect & Modularization

Architecture (MVI / MVVM with Clean Architecture)

  • Prefer MVI (Model-View-Intent) for state management. Ensure a strict unidirectional data flow:
    • UiState: Single source of truth for the UI state.
    • UiIntent: Actions initiated by the user or system.
    • UiEffect: One-time events (navigation, toasts, snackbars).
  • Separate the project into clean logical modules:
    • app: Application entry point, launcher activity, global dependency injection configuration.
    • core: Shared resources, network layer, media playback logic (ExoPlayer/Media3), storage.
    • feature: Individual business features (isolated and independent of other features).

Dependency Injection (Hilt)

  • Annotate the Application class with @HiltAndroidApp.
  • Annotate Activities and Fragments with @AndroidEntryPoint.
  • Use constructor injection for ViewModels with @HiltViewModel.

2. Jetpack Compose UI/UX

Recomposition & State Management

  • Consume StateFlow from ViewModels safely using collectAsStateWithLifecycle() to respect the activity lifecycle.
  • Keep data models immutable. Mark configuration classes with @Immutable or @Stable to prevent redundant recompositions.
  • Use contentType and key in LazyColumn and LazyRow to optimize item recycling and rendering performance.
  • Avoid fixed hardcoded margins. Apply WindowInsets to support modern edge-to-edge screens.

3. Performance & Multimedia (Media3 / ExoPlayer)

Playback & Services

  • Run ExoPlayer / Media3 inside a robust Foreground Service (using MediaSessionService) to ensure playback continues when the app is in the background.
  • Clean up resources: release player instances in onDestroy or when the service is stopped.
  • Control wake locks strictly to avoid draining the user's battery when playback is paused.

Kotlin Coroutines & Threading

  • Always inject CoroutineDispatcher instances instead of hardcoding them:
    • Dispatchers.IO: Database access, network operations, file reading.
    • Dispatchers.Default: CPU-intensive operations (parsing JSON, filtering large lists).
    • Dispatchers.Main: UI modifications and light interactions.

R8 & Resource Optimization

  • Enable shrinking and obfuscation in production builds:
    • isMinifyEnabled = true
    • isShrinkResources = true
  • Convert all static images to the modern WebP format to minimize the application binary size.

4. Quality Assurance & Automated Testing

Unit Testing

  • Use JUnit 5 and MockK for mocking dependencies.
  • Test ViewModels and Reducers by asserting StateFlow updates. Use Turbine to easily test Kotlin Flows.
  • Mock all multimedia/ExoPlayer components to avoid loading actual audio/video resources in unit tests.

UI Testing

  • Create UI tests using Compose test rules: createComposeRule() or createAndroidComposeRule<MainActivity>().
  • Assert correct rendering, visibility states, and user interactions without executing real network calls.

5. Key Gradle & ADB Commands

Use these commands for building, checking code style, running tests, and profiling performance:

CommandAction
./gradlew initInitialize a new Gradle project structure.
./gradlew app:dependenciesList all dependencies of the application module.
./gradlew assembleDebugValidate compilation and generate debug APK.
./gradlew ktlintCheckRun KtLint check to enforce Kotlin style guidelines.
./gradlew lintDebugRun Android Lint tool to inspect code quality and UI issues.
./gradlew testDebugUnitTestRun unit tests for debug build variant.
./gradlew connectedAndroidTestRun instrumented UI tests on connected emulator or device.
./gradlew assembleReleaseGenerate release build variant with R8 optimizations.
adb shell dumpsys batterystatsProfile system battery consumption metrics.
adb shell am dumpheap <package> heap.hprofDump application heap memory file for profiling.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use when adding monitoring, metrics, logging, or tracing to Spring AI or LLM integration code. Covers token tracking, latency measurement, cost estimation, and prompt/response logging. Use when user mentions AI monitoring, token costs, or LLM observability.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

Design, implement, review, and audit Android Jetpack Compose UI/UX for phone interfaces. Use when a request concerns concrete Compose layout, components, interaction, accessibility, or visual behavior. Do not activate for framework or dependency presence alone; non-UI Android work is excluded.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

Provides expert knowledge for designing, implementing, and managing REST API versioning strategies with deprecation workflows.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

astro

免费

Provides expert knowledge for building Astro 5+ sites with Islands Architecture, Content Collections, TypeScript, and performance-first rendering strategies.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

Audits token storage mechanisms to prevent XSS-based JWT theft.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

Provides patterns to configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Configures HikariCP connection pools, implements read/write splitting, sets up IAM database authentication, enables SSL connections, and integrates with AWS Secrets Manager. Use when setting up RDS connections in Spring Boot, configuring connection pooling, or managing database credentials securely.

中文简介正在准备中。当前显示原文说明。

lgzarturo/springboot-course32026年10月17日 更新

查看 lgzarturo 的全部技能

报告此技能的问题