android-kotlin

Installation
SKILL.md

android-kotlin

Purpose

This skill provides guidance on using Kotlin for Android development, focusing on key components like ViewModel for state management, LiveData or StateFlow for reactive data, coroutines with viewModelScope for asynchronous operations, Gradle KTS for build configuration, and KTX for Android extensions. It helps in building robust, maintainable Android apps.

When to Use

Use this skill when developing Android apps in Kotlin that require: managing UI state with ViewModel; handling asynchronous tasks like network calls using coroutines; observing data changes with LiveData or StateFlow; configuring projects via Gradle KTS; or simplifying code with KTX extensions. Apply it in scenarios involving activities, fragments, or services where lifecycle-aware components are needed.

Key Capabilities

  • ViewModel: Persists UI-related data across configuration changes; use androidx.lifecycle.ViewModel class.
  • LiveData/StateFlow: Observes data changes; LiveData integrates with lifecycle, StateFlow uses Kotlin flows for reactive programming.
  • Coroutines: Manage asynchronous code with viewModelScope.launch {} for scoped coroutines that cancel on ViewModel destruction.
  • Gradle KTS: Write build scripts in Kotlin script format for better type safety, e.g., build.gradle.kts.
  • KTX: Provides extension functions for Android APIs, like ContextCompat from androidx.core.

Usage Patterns

To implement MVVM architecture, create a ViewModel to hold data and business logic, then observe it in activities or fragments. For asynchronous operations, always launch coroutines within viewModelScope to avoid leaks. Use LiveData for simple observations or StateFlow for more advanced flows. When configuring Gradle, switch to KTS by renaming build.gradle to build.gradle.kts and updating syntax. Integrate KTX by adding dependencies in build.gradle.kts, e.g., implementation "androidx.core:core-ktx:1.7.0".

Related skills
Installs
22
GitHub Stars
5
First Seen
Mar 7, 2026