A 100% Kotlin-based project template that helps us kick start our Android projects.
- Dependencies managed
through Gradle version catalogs
*.toml
- Application signing, flavors & dimensions setup done
in
convention
using convention plugins - Supports
dev
&production
flavors out of the box - Lays the foundation for independent core business & presentation modules
network
,logger
,persistence
,session
- Dependency updates management is done through
gradle-versions
- Click the
Use this template
button on this page to generate your own project using this template or clone the project. - Open the project in Android Studio.
- Run the customize Kotlin script by right clicking the file and select
Run 'customize.kts
. The script will prompt you to input the package and app name. - Sync the project.
- Update signing configuration available in the Gradle DSL
plugin
SigningConfigPlugin
The template uses Gradle Kotlin DSL for build setup.
Dependencies are organized into a toml
configuration file - libs.versions.toml
.
Common module setup is done using convention plugins. The approach is based
on https://github.com/android/nowinandroid.
Modules should choose the plugin they need and specify it in the plugins { }
section of the build.gradle.kts
.
Android specific configuration is available in the Android
class.
This template adheres to the following architectural principles:
- An MVVM (Model-View-ViewModel) approach has been used for facilitating the GUI / business separation concerns.
- The app module uses a single-activity architecture, based on the Navigation component for navigation operations.
- It follows the S.O.L.I.D. software principles which help increasing flexibility & maintainability while keeping the code readable.
- A modular approach was used in order to improve on the separation of concerns topic, while also helping with isolating feature functionalities. This aspect also helps on the build speed on the long run as only modified modules will be recompiled at each run.
graph TD;
app-->feature:home;
feature:home-->core;
feature:home-->session;
feature:home-->logger;
feature:home-->config;
feature:home-->foundation:ui;
core-->network;
core-->persistence;
network-->session;
network-->config;
logger-->config;
The app module is the central place for all the other modules. It consists of a single Activity
which hosts all the
navigation inside the app and provides basic UI functionality for featureX
modules.
Represents a sample implementation of a feature
module. It showcases how the core
module provides all the needed
domain layer logic and the feature
module focuses only on
the presentation (also knows as the UI) layer.
It gathers logic from network
& persistence
modules and creates the required infrastructure to host the business
level Repositories
and UseCases
that it later exposes to the featureX
layer modules. It also hosts the UI models
and their respective converters. Most of the common business code is also hosted here (it's basically
a domain layer).
Provides a place to implement everything that's network related. It handles logic related to API calls, DTO models,
session handling through authentication headers and network level error handling. It
uses Retrofit & okhttp for the network layer
implementation and Moshi for json
parsing.
Provides a place to implement everything that's database caching related. It handles the logic for creating and migrating the database.
It also exposes a Dao
for each database table, so that the core
module can perform actions on each table. It uses
Room as the database implementation.
It handles everything related to a user session and saves current login state. Provides a way to listen for such state changes, while giving data about the current user and authentication information. It uses Jetpack DataStore under the hood for storing key-value pairs asynchronously.
Provides an implementation of basic console logging capabilities that can be easily extended to write to a file or any other use case. It uses Timber in the underlying implementation.
Provides build specific configuration to any module that needs it. Provided information is related to:
- app version code
- app version name
- app package identifier
- build flavor
- debug mode
This project uses ktlint, provided via the spotless gradle plugin.
Before pushing any code to the repository, please run the spotlessApply configuration to fix any
code style issues. You can also do this via command line by running ./gradlew spotlessApply
Copyright © 2022 Tapptitude
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.