Kriptofolio app series – Introduction: A roadmap to build a modern Android app in 2018-2019
Welcome to this series of blog posts where I will be creating a modern Android app. I will use the best tools and practices available in the year 2018-2019. I am doing this because I want to cover all the hottest topics in Android world and acquire knowledge in them by teaching you.
If you follow this series, you will learn how to develop the app from scratch. Each blog post from this series will cover some specific development topic which I want to talk about. I will try to do my best to create a good quality app and explain the development process. This first blog post from the series is a project’s roadmap of what we are going to do.
Please note: this introduction will be frequently updated as I will progress through different parts of the blog posts series.
Series content
- Introduction: A roadmap to build a modern Android app in 2018-2019 (you’re here)
- Part 1: SOLID principles
- Part 2: Mockups, UI, XML layouts
- Part 3: Architecture patterns MVC, MVP, MVVM with Android Architecture Components – ViewModel, LiveData, Data Binding, Room
- Part 4: Dependency Injection with Dagger 2
- Part 5: Handle RESTful Web Services using Retrofit, OkHttp, Gson, Glide and Coroutines
The app: “Kriptofolio” (previously “My Crypto Coins”) idea
At first it was hard to think of a plan to showcase all Android development trends, but finally, I found one which I liked. It is related to my huge interest area — blockchain and cryptocurrencies. I decided to create an app which would contain your cryptocurrencies portfolio and let you know how much they are worth converted to fiat money.
The important thing for the user is that this app is going to ensure 100% trust. It will not require any login/registration process. It won’t collect users’ data by sending it to the server. I guess nobody would feel comfortable sharing information online about owned money.
Users’ provided data about cryptocurrency investments will be only stored inside a local database that is kept inside an Android device. However, to know the portfolio’s value converted to the fiat money, the app is going to use the Internet to get the latest conversion rates.
So as you see for training purposes, this app idea is great. It is technically challenging you to try different approaches to work with data. This is one of the most important skills to know to build modern apps. The topic of money for people is so sensitive. To ensure even more trust, I will be developing this app openly by creating this blog posts series and making the project code available so everyone can see that there is nothing to hide.
What are we going to use?
First, to create this app, we need to know about various cryptocurrency prices at the current moment. This data will be provided from the Internet as it is continually changing.
Data API:
CoinMarketCap — one of the most popular websites for getting an overview of the cryptocurrency market. This website offers a free API that anyone can use and it fits perfectly for us as a data service provider.
Next, I made a list of my most significant trending things in the Android world that fit this project and should be used in it.
Programming language:
Kotlin — an official language on Android. It is expressive, concise, and powerful. Best of all, it’s interoperable with existing Android languages and runtime.
This new language introduction was one of the hottest topics in 2017 for Android. Our app needs to be written in it. I also talk about Kotlin and its features in my past blog post “Let’s learn Kotlin by building Android calculator app”.
Integrated development environment (IDE):
Android Studio — the official IDE for Android. It provides the fastest tools for building apps on every type of Android device. There are no better alternatives for developing native apps. It’s our main choice for an IDE without any question.
Project build management system:
Gradle — is an advanced general purpose build management system based on Groovy and Kotlin. It supports the automatic download and configuration of dependencies or other libraries. It is the recommended build system by Google. It is well integrated inside Android Studio so we will be using it.
Architecture:
Android Architecture Components — a collection of libraries that help you design robust, testable, and maintainable apps.
Model–View–ViewModel (MVVM) — it’s an architectural pattern. The concept is to separate data presentation logic from business logic by moving it into particular class for a clear distinction. The Android team is pushing this pattern as the default choice. Also, it’s an alternative to MVC and popular MVP patterns.
I’ll be talking separately in this series about this pattern choice, other architecture options and how to organize our code well in general. It is essential if we want to build an easily maintainable solid project.
Coroutines - a concurrency design pattern that you can use on Android to simplify code that executes asynchronously.
Data persistence:
SQLite Database — it is an open source SQL database that stores data persistently to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features.
Shared Preferences — an API from Android SDK to store and retrieve application preferences. SharedPreferences are merely sets of data values stored persistently. It allows you to save and retrieve data in the form of key value pairs.
Libraries:
Android Jetpack components:
AppCompat — it is a set of support libraries which can be used to make the apps that were developed with newer versions work with older versions.
Android KTX — a set of Kotlin extensions for Android app development. The goal of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging the features of the language such as extension functions/properties, lambdas, named parameters, and parameter defaults.
Data Binding — is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.
Lifecycles — for managing your activity and fragment lifecycles.
LiveData — is an observable data holder class which was designed to help solve common Android Lifecycle challenges and to make apps more maintainable and testable.
Room — it provides an abstraction layer over SQLite to allow easy 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.
Other:
ConstraintLayout — for building flexible and efficient layouts. The Layout Editor uses constraints to determine the position of a UI element within the layout. A constraint represents a connection or alignment to another view, the parent layout, or an invisible guideline.
CardView — element which represents the information in a card manner with a drop shadow (elevation) and corner radius which looks consistent across the platform.
RecyclerView — a flexible and efficient version of ListView. It is a container for rendering large data set of views that can be recycled and scrolled very efficiently.
Third-party:
Dagger 2 — this is an entirely static, compile-time dependency injection framework for both Java and Android.
Retrofit 2 — an open source type-safe HTTP client for Android and Java. With Retrofit, we can compose the HTTP connection easily through a simple, expressive interface just like an API document.
OkHttp — an open source modern, fast and efficient HTTP client which supports HTTP/2 and SPDY.
Gson — an open source Java library to serialize and deserialize Java objects to and from JSON.
Glide — a fast and efficient image loading library for Android focused on smooth scrolling. Glide offers an easy to use API, a performant and extensible resource decoding pipeline and automatic resource pooling.
Configuring a new project
We will create this project from scratch. So I’ll launch Android Studio, create a new Project, name it “My Crypto Coins” and select “Basic Activity”. At this point, there is nothing special to discuss. Our goal is to make a fresh, clean start and avoid any complexity in our minds by adding additional features (e.g., instant app support). We can add anything later if we want during the development process.
For a start let’s include Kotlin language support and target API 23: Android 6.0 (Marshmallow).
Why am I not targeting a lower or higher API? Let’s face it. It’s nice to cut the support for some older devices and not worry about many compatibility issues during development. Also, I am a proud owner of an old Nexus 7 (2013) tablet, which is running Android 6.0.1. I hope to test my app live on it. 🙂 So for this individual project that impacted my minimum SDK choice.
Also as you’ve noticed, I am going to ask IDE to add automatically generated basic activity with fragment support and a floating action button. I feel all that could be useful for our project.
Repository
GitHub — one of the most popular web-based hosting service for version control. This is an open source project, and of course, I will be using it.
All the blog posts from this series will have its commits made as separate branches and the master branch for the latest source code version. Here is a link for you to the repository.
That’s it for the start. If you have any questions, suggestions, remarks to make, please feel free to do that in comments. And now let’s learn together! Part 2 is up next… 😉
This post was also republished on Medium. Show your support by clicking the clap button 👏 on the story page here. 😇🙏