An Android project template, written completely in Kotlin, to help you kick start your next Android project in seconds.
This template has Static Analysis and Continuous Integration already set up.
- How to use
- Features
- Gradle Setup
- Git Hooks
- Static Analysis
- Code Formatting
- Dependency Updates
- CI
- Documentation
- Architecture
- Contributions
- License
Just click on the button to create a new repo starting from this template.
Once created don't forget to update the:
- Android Configuration for App ID and other required Information.
- App ID in
app/src/main/AndroidManifest.xml
andcore/src/main/AndroidManifest.xml
. - Package of the source files.
- Copyright.
- Run
./gradlew spotlessApply
to update the copyright across the project. - Run
./gradlew installGitHooks
task to install Git Hooks.
- 100% Kotlin-only template.
- 100% Gradle Kotlin DSL setup.
- Dependencies managed via
buildSrc
. - Common gradle scripts for
android-library
,kotlin-library
&android-dynamic-feature
. - 3 Sample modules (
Android app
,Android library
,Kotlin library
). - Product flavours.
dev
,qa
,prod
. - Kotlin Static Analysis using
ktlint
&detekt
. - Code formatting using
spotless
. - Dependency updates management using
gradle-versions
. - Git Hooks to make sure you commit the code that passes all the Static Analysis tests.
- CI setup with GitHub Actions.
- Issues Template (bug report + feature request).
- Pull Request Template.
This template is using Gradle Kotlin DSL as well as the Plugin DSL to setup the build.
Android Config contains Android specific configurations.
Dependencies are centralized inside the Dependencies.kt file in the buildSrc
folder. This provides convenient auto-completion when writing your gradle files.
Common gradle scripts are placed inside the commons package to help reduce boilerplate code when creating a new module. Refer to core/build.gradle.kts
or library/build.gradle.kts
file for usage examples.
Git Hooks allow running a pre commit script to make sure the code complies with the coding style before making a commit. Run ./gradlew installGitHooks
task to install Git Hooks.
This template is using ktlint with the ktlint-gradle plugin to format your code. To reformat all the source code as well as the buildscript you can run the ktlintFormat
gradle task.
Run ./gradlew ktlintCheck
to check if the there are any lint issues.
Run ./gradlew ktlintFormat
to format the code across the project.
This template is using detekt to analyze the source code, with the configuration that is stored in the config.yml file (the file has been generated with the detektGenerateConfig
task).
Run ./gradlew detekt
to analyze the code.
Alternatively, you can Run scripts/process-code.sh
to fix the code style and update the copyright all at once.
This template is using spotless to format the code, and apply copyright.kt header to all the files in the project.
Run ./gradlew spotlessCheck
to check if the copyright is up to date.
Run ./gradlew spotlessApply
to update the copyright across the project.
This template is using gradle-versions to generate dependency updates report.
Run ./gradlew dependencyUpdates
to generate dependency updates report.
This template is using Github Actions for CI.
These are the workflows currently available.
- Build - Will run the
build
task whenever there is a new push to any branch other than the master. - Deploy App - For every pull request merged to the master branch, it will run the
build
&bundleRelease
tasks followed by signing the bundle and publishing it to the Play store.
Github Actions are integrated with Slack, you get the updates on Slack.
Add the following SECRETS to the repository
SLACK_WEBHOOK_URL
SIGNING_KEY
KEY_STORE_PASSWORD
ALIAS
KEY_PASSWORD
Run the following command to generate Signing key string
openssl base64 < some_signing_key.jks | tr -d '\n' | tee some_signing_key.jks.base64.txt
This template is using dokka to generate Documentation for the codebase. Use gradle tasks in documentation
to generate documentation in required format.
The architecture of the template is based, apply and strictly complies with each of the following 5 points:
- A single-activity architecture, using the Navigation component to manage fragment operations.
- Android architecture components, part of Android Jetpack for give to project a robust design, testable and maintainable.
- Pattern Model-View-ViewModel (MVVM) facilitating a separation of development of the graphical user interface.
- S.O.L.I.D design principles intended to make software designs more understandable, flexible and maintainable.
- Modular app architecture allows to be developed features in isolation, independently from other features.
Modules are collection of source files and build settings that allow you to divide a project into discrete units of functionality. In this case apart from dividing by functionality/responsibility, existing the following dependence between them:
:app
depends on:core
.:core
and:library
don’t have any dependency.
The template has different product flavours: Dev
, QA
, Prod
. Each variant has a specific target environment. Different flavours use different assets for debug
and release
build variant with descriptive app names.
For more information about build variant, check this link.
Types | DEV | QA | PROD |
---|---|---|---|
Debug | |||
Release |
Avoid reinventing the wheel by following these guidelines:
Google Developers Codelabs provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through the process of building a small application, or adding a new feature to an existing application. They cover a wide range of android concepts to learn and practice:
In Future Maybe
Copyright 2021 Vishal Choudhary
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.