install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/new-silvermoon/awesome-android-agent-skills/android-architecture" ~/.claude/skills/comeonoliver-skillshub-android-architecture-9fc7f5 && rm -rf "$T"
manifest:
skills/new-silvermoon/awesome-android-agent-skills/android-architecture/SKILL.mdsource content
Android Modern Architecture & Modularization
Instructions
When designing or refactoring an Android application, adhere to the Guide to App Architecture and Clean Architecture principles.
1. High-Level Layers
Structure the application into three primary layers. Dependencies must strictly flow inwards (or downwards) to the core logic.
- UI Layer (Presentation):
- Responsibility: Displaying data and handling user interactions.
- Components: Activities, Fragments, Composables, ViewModels.
- Dependencies: Depends on the Domain Layer (or Data Layer if simple). Never depends on the Data Layer implementation details directly.
- Domain Layer (Business Logic) [Optional but Recommended]:
- Responsibility: Encapsulating complex business rules and reuse.
- Components: Use Cases (e.g.,
), Domain Models (pure Kotlin data classes).GetLatestNewsUseCase - Pure Kotlin: Must NOT contain any Android framework dependencies (no
imports).android.* - Dependencies: Depends on Repository Interfaces.
- Data Layer:
- Responsibility: Managing application data (fetching, caching, saving).
- Components: Repositories (implementations), Data Sources (Retrofit APIs, Room DAOs).
- Dependencies: Depends only on external sources and libraries.
2. Dependency Injection with Hilt
Use Hilt for all dependency injection.
- @HiltAndroidApp: Annotate the
class.Application - @AndroidEntryPoint: Annotate Activities and Fragments.
- @HiltViewModel: Annotate ViewModels; use standard
injection.constructor - Modules:
- Use
and@Module
for app-wide singletons (e.g., Network, Database).@InstallIn(SingletonComponent::class) - Use
in an abstract class to bind interface implementations (cleaner than@Binds
).@Provides
- Use
3. Modularization Strategy
For production apps, use a multi-module strategy to improve build times and separation of concerns.
- :app: The main entry point, connects features.
- :core:model: Shared domain models (Pure Kotlin).
- :core:data: Repositories, Data Sources, Database, Network.
- :core:domain: Use Cases and Repository Interfaces.
- :core:ui: Shared Composables, Theme, Resources.
- :feature:[name]: Standalone feature modules containing their own UI and ViewModels. Depends on
and:core:domain
.:core:ui
4. Checklist for implementation
- Ensure
layer has no Android dependencies.Domain - Repositories should default to main-safe suspend functions (use
internally if needed).Dispatchers.IO - ViewModels should interact with the UI layer via
(seeStateFlow
skill).android-viewmodel