Dependencies
Explore the main Android dependencies critical for applying MVVM architecture in Kotlin. Understand how libraries such as Room for local data caching, Retrofit and OkHttp for networking, Coroutines for concurrency, and Glide for image loading integrate into your project to build maintainable and efficient apps.
In this chapter, we’ll look at Android dependencies and see how they’re involved in our application and the project structure, which is located in the Appendix.
Let’s look at each of the dependencies above and how they’re related to our application.
The RoomDatabase dependency
The Room library is built on top of the SQLite database acting as an abstraction layer and serves as a data persistence library used to cache data locally when online. We can also access this data while offline. To use it, we first add the following dependency to our build.gradle file:
Why to use Room
- It’s easy to use since all the boilerplate code we had to write while using SQLite database is now abstracted and provided automatically in the background.