Skip to content

ashtanko/compose-android-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

387 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Android Compose Template πŸš€

Use this template Android CI License Language

A modern, production-ready Android template built with Jetpack Compose, Navigation 3, and Kotlin. This template provides a solid foundation for building Android applications with best practices, comprehensive testing, and CI/CD already configured.

🎯 Quick Start

Using the Template

  1. Click the Use this template button.

  2. Clone your new repository.

  3. Run the rename script to replace template package names, applicationId, plugin aliases, folder structure, and (optionally) copyright headers with your own:

    # preview first
    ./scripts/rename-template.sh \
        --package com.example.myapp \
        --name "My Awesome App" \
        --author "Your Name" \
        --dry-run
    
    # apply
    ./scripts/rename-template.sh \
        --package com.example.myapp \
        --name "My Awesome App" \
        --author "Your Name"

    Or via Gradle (same flags, -P-style):

    ./gradlew renameProject \
        -Ppackage=com.example.myapp \
        -Pname="My Awesome App" \
        -Pauthor="Your Name" \
        -PdryRun=true   # drop this to apply

    After applying, run ./gradlew spotlessApply then ./gradlew clean assembleDebug to verify.

  4. Update SDK and library versions in gradle/libs.versions.toml as needed (single source of truth for dependencies and plugin versions).

Building the Project

# Build the project
./gradlew assembleDebug

# Run unit tests
./gradlew test

# Run linting and static analysis
./gradlew detekt

# Format code
./gradlew spotlessApply

πŸ—οΈ Project Architecture

The project follows a modular layout backed by Gradle convention plugins:

β”œβ”€β”€ app/                    # Main Android application (Compose + Navigation 3)
β”œβ”€β”€ library-android/        # Android-specific library module
β”œβ”€β”€ library-kotlin/         # Pure Kotlin library module (business logic)
β”œβ”€β”€ benchmarks/             # Macrobenchmark + baseline profile generator
β”œβ”€β”€ build-logic/            # Shared Gradle convention plugins (includeBuild)
β”œβ”€β”€ buildSrc/               # Project-wide build configuration
β”œβ”€β”€ gradle/                 # Version catalog (libs.versions.toml)
β”œβ”€β”€ config/                 # Detekt / KtLint / static-analysis configs
β”œβ”€β”€ spotless/               # Spotless copyright header template
└── scripts/                # Helper scripts (e.g. rename-template.sh)

Convention plugins under build-logic/convention (e.g. androidlab.android.application, androidlab.android.library.compose, androidlab.hilt, androidlab.android.room, androidlab.android.lint) keep per-module build.gradle.kts files small and consistent.

πŸ› οΈ Technology Stack

Core Technologies

  • Kotlin 2.3.21 β€” with Strong Skipping support.
  • Android Gradle Plugin 9.2.1 β€” latest build system features.
  • Jetpack Compose β€” Compose BOM 2026.05.00, Material 3, Material 3 Adaptive.
  • Navigation 3 (1.1.1) alongside androidx.navigation:navigation-compose (2.9.8).
  • Kotlin Coroutines 1.11.x and kotlinx.serialization 1.11.x.

Architecture & Dependencies

  • Hilt 2.59.2 β€” dependency injection (+ hilt-navigation-compose).
  • Room 2.8.x β€” local persistence (via KSP).
  • Retrofit 3.0.0 + OkHttp 5.3.x β€” type-safe networking with kotlinx-serialization converter.
  • Sandwich 2.2.x β€” Retrofit response wrapping.
  • Paging 3 β€” smooth list loading.
  • Coil 2.7 β€” image loading optimized for Compose.
  • kotlinx-datetime and kotlinx.collections.immutable.

Testing & Quality

  • JUnit 5 (6.0.x) β€” modern unit testing.
  • Roborazzi 1.60.x β€” screenshot / golden-image testing.
  • Compose Guard β€” Compose compiler stability metrics.
  • Kover 0.9.x + JaCoCo 0.8.x β€” coverage reports.
  • Detekt 1.23.x + KtLint + Spotless 8.4.x β€” static analysis & formatting.
  • Dependency Guard β€” transitive dependency change detection.
  • MockK + Mockito + Turbine + Truth + AssertJ β€” testing toolkit.
  • Robolectric & Espresso β€” JVM- and device-side instrumentation.

πŸ“± Features

  • Adaptive Layouts β€” foldables and tablets via Material 3 Adaptive.
  • Edge-to-Edge β€” modern UI implementation by default.
  • Baseline Profiles β€” generated via :benchmarks for faster startup and smoother frames.
  • Screenshot Testing β€” automated UI regression with Roborazzi + the Compose screenshot plugin.
  • Dependency Guard β€” locks transitive dependency surface across builds.
  • Signing-ready β€” release signingConfig resolves keystore credentials from env vars on CI (SIGNING_STORE_PASSWORD, SIGNING_KEY_ALIAS, SIGNING_KEY_PASSWORD) or secrets.defaults.properties locally.

πŸ§ͺ Testing

# Run unit tests (JUnit 5)
./gradlew test

# Screenshot tests (Roborazzi)
./gradlew recordRoborazziDebug   # record new baselines
./gradlew verifyRoborazziDebug   # compare against baselines

# Coverage
./gradlew koverHtmlReport

# Instrumentation tests
./gradlew :app:connectedDebugAndroidTest

# Macrobenchmarks & baseline profile
./gradlew :benchmarks:connectedDebugAndroidTest
./gradlew :app:generateBaselineProfile

πŸš€ Available Commands (Makefile)

The Makefile wraps common Gradle invocations:

  • make / make default β€” build, test, lint, detekt, plus updateDebugScreenshotTest and validateDebugScreenshotTest.
  • make check β€” run Detekt.
  • make ktlint β€” run KtLint check.
  • make spotless β€” run Spotless apply + check.
  • make test β€” JVM unit tests.
  • make android-test β€” :app:connectedDebugAndroidTest.
  • make screenshot β€” update + validate screenshot tests.
  • make robo β€” clear β†’ record β†’ compare β†’ verify Roborazzi screenshots.
  • make kover β€” generate Kover HTML coverage report.
  • make jacoco β€” copy the JaCoCo HTML report to jacocoReport/.
  • make guard-baseline β€” refresh Dependency Guard baselines.
  • make benchmark β€” run macrobenchmarks.
  • make baseline-profile β€” generate baseline profile for :app.
  • make lines / make cloc β€” Kotlin LoC stats.

πŸ“‹ Requirements

  • Android Studio β€” Ladybug or newer.
  • JDK 21 β€” required for the build system (set as Kotlin/Java toolchain).
  • Android SDK β€” compileSdk / targetSdk: 37, minSdk: 24.
  • Gradle β€” uses the wrapper (./gradlew); AGP 9.2.x.

🀝 Contributing

  1. Fork the repository.
  2. Create a feature branch.
  3. Ensure all CI checks pass.
  4. Submit a pull request.

πŸ“„ License

This project is licensed under the Apache License 2.0 β€” see the LICENSE file for details.

About

πŸ“± A simple GitHub template to quickly set up an Android project using Kotlin and Jetpack Compose, getting you up and running in just seconds. Perfect for starting new apps with modern Android UI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors