Skip to content

πŸ“± 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.

License

Notifications You must be signed in to change notification settings

ashtanko/compose-android-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Android Compose Template πŸš€

Use this template Android CI License Language

A modern, production-ready Android template built with Jetpack Compose 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 to create a new repository
  2. Clone your new repository
  3. Update the following files with your project details:
    • buildSrc/src/main/kotlin/dev/shtanko/template/Configuration.kt - Update version and SDK configurations
    • app/src/main/AndroidManifest.xml - Update package name and permissions
    • library-android/src/main/AndroidManifest.xml - Update package name
    • Rename package directories to match your project structure

Building the Project

# Build the project
./gradlew build

# Run tests
./gradlew test

# Run linting and code analysis
./gradlew detekt

# Format code
./gradlew spotlessApply

πŸ—οΈ Project Architecture

This template follows a modular architecture with the following structure:

β”œβ”€β”€ app/                    # Main Android application module
β”œβ”€β”€ library-android/        # Android library module
β”œβ”€β”€ library-kotlin/         # Kotlin-only library module
β”œβ”€β”€ buildSrc/              # Build configuration and dependencies
β”œβ”€β”€ gradle/                # Version catalogs and build scripts
β”œβ”€β”€ config/                # Static analysis configuration
└── .github/workflows/     # CI/CD workflows

Module Structure

  • app: Main Android application with Compose UI
  • library-android: Reusable Android components and utilities
  • library-kotlin: Platform-agnostic business logic and data models

πŸ› οΈ Technology Stack

Core Technologies

  • Kotlin - Primary programming language
  • Jetpack Compose - Modern UI toolkit
  • Material 3 - Design system
  • Android Gradle Plugin 8.10.1 - Build system
  • Gradle Kotlin DSL - Build configuration

Architecture & Dependencies

  • Hilt - Dependency injection
  • Room - Local database
  • Retrofit + OkHttp - Network communication
  • Kotlinx Serialization - JSON serialization
  • Paging 3 - Pagination support
  • Navigation Compose - Navigation
  • WorkManager - Background tasks
  • Coil - Image loading

Testing Framework

  • JUnit 5 - Unit testing
  • Espresso - UI testing
  • Robolectric - Android framework testing
  • Mockito/MockK - Mocking
  • Turbine - Flow testing
  • Roborazzi - Screenshot testing

Code Quality & Analysis

  • Detekt - Static code analysis
  • KtLint - Code formatting
  • Spotless - Code formatting
  • SonarQube - Code quality analysis
  • Kover - Code coverage
  • Jacoco - Coverage reporting

πŸ“± Features

UI/UX

  • Material 3 Design System - Modern, adaptive design
  • Dark/Light Theme Support - Complete theming system
  • Responsive Layout - Adaptive to different screen sizes
  • Accessibility Support - WCAG compliance ready
  • Splash Screen - Modern splash screen implementation

Development Experience

  • Hot Reload - Fast development with Compose
  • Type Safety - Full Kotlin type safety
  • Auto-completion - Enhanced IDE support
  • Debug Tools - Comprehensive debugging utilities

Performance

  • Baseline Profiles - Performance optimization
  • Benchmarking - Performance measurement tools
  • Memory Leak Detection - Built-in memory analysis
  • ProGuard/R8 - Code optimization and obfuscation

πŸ”§ Configuration

Build Configuration

The project uses centralized dependency management through gradle/libs.versions.toml:

// Example dependency usage
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.navigation.compose)
implementation(libs.hilt.android)

Static Analysis

Configure code quality tools in their respective config files:

  • Detekt: config/detekt/detekt.yml
  • KtLint: Configured via Gradle plugin
  • Spotless: Configured in build.gradle.kts

CI/CD Pipeline

The template includes GitHub Actions workflows for:

  • Build & Test: Automated testing on every PR
  • Code Quality: Static analysis and formatting checks
  • Publishing: Automated library publishing (configurable)

πŸ§ͺ Testing

Unit Tests

# Run all unit tests
./gradlew testDebugUnitTest

# Run tests with coverage
./gradlew koverHtmlReport

UI Tests

# Run Espresso tests
./gradlew connectedAndroidTest

# Run screenshot tests
./gradlew updateDebugScreenshotTest
./gradlew validateDebugScreenshotTest

Code Quality Checks

# Run static analysis
./gradlew detekt

# Check code formatting
./gradlew ktlintCheck

# Apply code formatting
./gradlew spotlessApply

πŸ“¦ Publishing

Library Publishing

The template is configured for publishing to Maven Central. Configure the following secrets:

Secret Description
ORG_GRADLE_PROJECT_NEXUS_USERNAME Sonatype username
ORG_GRADLE_PROJECT_NEXUS_PASSWORD Sonatype password
ORG_GRADLE_PROJECT_SIGNING_KEY GPG private key
ORG_GRADLE_PROJECT_SIGNING_PWD GPG passphrase

Publishing Workflows

  • Snapshot Publishing: Automatic on merge to main
  • Release Publishing: Triggered by version tags

πŸš€ Available Commands

Use the provided Makefile for common tasks:

# Build and test everything
make default

# Run code quality checks
make check

# Format code
make spotless

# Generate coverage report
make kover

# Run screenshot tests
make screenshot

πŸ“‹ Requirements

  • Android Studio - Latest stable version
  • JDK 17 - Java Development Kit
  • Android SDK - API level 33+ (Android 13+)
  • Gradle - 8.0+ (included via wrapper)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and quality checks
  5. Submit a pull request

Development Guidelines

  • Follow Kotlin coding conventions
  • Write unit tests for new features
  • Ensure all CI checks pass
  • Update documentation as needed

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built on top of the excellent kotlin-android-template
  • Uses modern Android development best practices
  • Incorporates community-driven improvements

Ready to build amazing Android apps? πŸŽ‰ Start with this template and focus on what matters most - your app's features and user experience!

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

No packages published

Contributors 4

  •  
  •  
  •  
  •