Skip to content

Latest commit

 

History

History
195 lines (132 loc) · 10.9 KB

README.md

File metadata and controls

195 lines (132 loc) · 10.9 KB

Android Template

CodeStyle Build Kotlin Version Gradle API License

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.

Table of Contents

How to use

Just click on the Use this template button to create a new repo starting from this template.

Once created don't forget to update the:

Features

Gradle Setup

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

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.

Static Analysis

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.

Code Formatting

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.

Dependency Updates

This template is using gradle-versions to generate dependency updates report.

Run ./gradlew dependencyUpdates to generate dependency updates report.

CI

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

Documentation

This template is using dokka to generate Documentation for the codebase. Use gradle tasks in documentation to generate documentation in required format.

Architecture

The architecture of the template is based, apply and strictly complies with each of the following 5 points:

Modules

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.

Build variants

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


AndroidTemplateDEV


AndroidTemplateQA


AndroidTemplate

Release


AndroidTemplateDEV


AndroidTemplateQA


AndroidTemplate

Best practices

Avoid reinventing the wheel by following these guidelines:

Codelabs

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:

Contributions

In Future Maybe

License

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

    http://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.