Kotlin Sample App is a sample project that presents modern, 2019 approach to Android application development using Kotlin and latest tech-stack.
The goal of the project is to demonstrate best practices, provide a set of guidelines, and present modern Android application architecture that is modular, scalable, maintainable and testable. This application may look simple, but it has all of these small details that will set the rock-solid foundation of the larger app suitable for bigger teams and long application lifecycle management.
Mode | Characters list | Characters favorite | Character detail |
---|---|---|---|
Light | |||
Dark |
First off, you require the latest Android Studio 3.5 (or newer) to be able to build the app.
You need to supply API keys for the various services the app uses. That is currently Marvel and Fabric (Crashlytics). You can find information about how to gain access via these relevant links.
- Marvel: https://developer.marvel.com/
- Firebase: https://get.fabric.io/
When you obtain the keys, you can provide them to the app by putting the following in the local.properties
project root file:
#Marvel API KEYS
marvel.key.public = <insert>
marvel.key.private = <insert>
#Fabric API KEYS
fabric.key = <insert>
fabric.secret = <insert>
Moreover, to sign your app for release you should generate an upload key and keystore following the official documentation. Append the information used to generate it into local.properties
project root file following the structure:
#Signing Config
signing.key.alias = <insert>
signing.key.password = <insert>
signing.store.file = <insert>
signing.store.password = <insert>
//TODO
This project takes advantage of many popular libraries, plugins and tools of the Android ecosystem. Most of the libraries are in the stable version, unless there is a good reason to use non-stable dependency.
- Jetpack:
- Android KTX - provide concise, idiomatic Kotlin to Jetpack and Android platform APIs.
- AndroidX - major improvement to the original Android Support Library, which is no longer maintained.
- Benchmark - handles warmup, measures your code performance, and outputs benchmarking results to the Android Studio console.
- Data Binding - allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.
- Lifecycle - perform actions in response to a change in the lifecycle status of another component, such as activities and fragments.
- LiveData - lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services.
- Navigation - helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer.
- Paging - helps you load and display small chunks of data at a time. Loading partial data on demand reduces usage of network bandwidth and system resources.
- Room - persistence library provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.
- ViewModel - designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.
- Coroutines - managing background threads with simplified code and reducing needs for callbacks.
- Dagger2 - dependency injector for replacement all FactoryFactory classes.
- Retrofit - type-safe HTTP client.
- Glide - image loading and caching library for Android focused on smooth scrolling.
- Moshi - makes it easy to parse JSON into Kotlin objects.
- Timber - a logger with a small, extensible API which provides utility on top of Android's normal Log class.
- Stetho - debug bridge for applications via Chrome Developer Tools.
- and more...
- UIAutomator - a UI testing framework suitable for cross-app functional UI testing across system and installed apps.
- Espresso - to write concise, beautiful, and reliable Android UI tests
- Robolectric - industry-standard unit testing framework for Android.
- JUnit - a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.
- Mockito - most popular Mocking framework for unit tests written in Java.
- AndroidX - the androidx test library provides an extensive framework for testing Android apps.
- and more...
- Ktlint - an anti-bikeshedding Kotlin linter with built-in formatter.
- Detekt - a static code analysis tool for the Kotlin programming language.
- Spotless - a code formatter can do more than just find formatting errors.
- Versions - make easy to determine which dependencies have updates.
- SafeArgs - generates simple object and builder classes for type-safe navigation and access to any associated arguments.
- Jacoco - code coverage library
- and more...
This is project is a sample, to inspire you and should handle most of the common cases, but obviously not all. If you need to take a look at additional resources to find solutions for your project, visit these interesting projects:
- iosched (by google) - official Android application from google IO 2019.
- plaid (by android) - app which provides design news & inspiration, being an example of implementing material design.
- sunflower (by android) - a gardening app illustrating Android development best practices with Android Jetpack.
- architecture-components-samples (by android) - collection of samples for Android Architecture Components.
- architecture-sample (by android) - collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
- android-clean-architecture-boilerplate (by bufferapp) - an android boilerplate project using clean architecture
- android-kotlin-clean-architecture (by sanogueralorenzo) - android sample Clean Architecture app written in Kotlin.
- modularization-example (by JeroenMols) - easy to understand real-life example of a modularized Android app.
- lego-catalog (by Eli-Fox) - app illustrating current Android Architecture state using Android development best practices.
- android-showcase (by igorwojda) - app following best practices: Kotlin, coroutines, Clean Architecture, feature modules, tests, MVVM, static analysis.
A collection of very interesting articles related last android community tendencies and recommendations for start to take in consideration for your current/next project:
- Transform monolith to modularization application
- Using the Navigation Component in a Modular World
- Dependency injection in a multi module project
- ViewModels and LiveData: Patterns + AntiPatterns
- Dynamic feature and regular modules using Dagger2
- Android Architecture starring Kotlin Coroutines, Jetpack (MVVM, Room, Paging), Retrofit and Dagger 2
- Official Kotlin Style Guide with Ktlint
- Gradle dependency management with Kotlin (buildSrc)
- Detecting Kotlin Code Smells with Detekt
- Best coding practices, tips and more for Android
The open-source community create and maintains tons of awesome libraries making your job more easy, giving the opportunity to use them in your developments. Here are a very important collection of them:
- awesome-android-ui - collection list of awesome Android UI/UX libraries.
- awesome-android-libraries - collection of awesome Kotlin related stuff.
- android-arsenal - android developer portal with tools, libraries, and apps.
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:
All contributions are welcome! Please feel free to post questions, recommendations, ideas, bugs by create new issue following the template or if you want create directly new pull request.
Copyright 2019 vmadalin.com
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.