Clean Android Architecture: Take a layered approach to writing clean, testable, and decoupled Android applications
Learn how to build, maintain, and test Android applications using clean architecture principles
- Understand various software design principles and patterns to make an application more testable
- Structure your application’s code into different layers and components to make it more maintainable and flexible
- Study popular libraries and frameworks and integrate them into an application
As an application’s code base increases, it becomes harder for developers to maintain existing features and introduce new ones. In this clean architecture book, you’ll learn to identify when and how this problem emerges and how to structure your code to overcome it.
The book starts by explaining clean architecture principles and Android architecture components and then explores the tools, frameworks, and libraries involved. You’ll learn how to structure your application in the data and domain layers, the technologies that go in each layer, and the role that each layer plays in keeping your application clean. You’ll understand how to arrange the code into these two layers and the components involved in assembling them. Finally, you’ll cover the presentation layer and the patterns that can be applied to have a decoupled and testable code base.
By the end of this architecture book, you’ll be able to build an application following clean architecture principles and have the knowledge you need to maintain and test the application easily.
What you will learn
- Discover and solve issues in Android legacy applications
- Become well versed in the principles behind clean architecture
- Get to grips with writing loosely coupled and testable code
- Find out how to structure an application’s code in separate layers
- Understand the role each layer plays in keeping the application clean
- Integrate existing frameworks and libraries for each layer
Who this book is for
This book is for Android developers who want to learn about managing the complexity of their applications, and is also highly recommended for intermediate or advanced Android developers looking for a go-to guide for clean architecture and the integration of various Android technologies. New developers familiar with the fundamentals of Android app development will find this book useful too.
Clean Android Architecture Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Code in Action Download the color images Conventions used Get in touch Share Your Thoughts Part 1 – Introduction Chapter 1: Getting Started with Clean Architecture Technical requirements The architecture of a legacy app Legacy analysis Software design principles SOLID principles Component cohesion principles Component coupling principles Exploring the evolution of Android Fragments The Gradle build system Networking Humble objects Functional paradigms Kotlin adoption Dependency injection Android architecture components Coroutines and flows Jetpack Compose Enter clean architecture Summary Chapter 2: Deep Diving into Data Sources Technical requirements Understanding Kotlin coroutines and Flows Kotlin coroutines Exercise 02.01 – Using Kotlin coroutines Kotlin Flows Exercise 02.02 – Using Kotlin Flows Using OkHttp and Retrofit for networking Exercise 02.03 – Using OkHttp and Retrofit Using the Room library for data persistence Exercise 02.04 – Using Room to persist data Understanding and using the DataStore library Exercise 02.05 – Using DataStore to persist data Summary Chapter 3: Understanding Data Presentation on Android Technical requirements Analyzing lifecycle-aware components Exercise 3.1 – Using ViewModel and LiveData Using Jetpack Compose to build UIs Exercise 3.2 – Navigating using Jetpack Compose Summary Chapter 4: Managing Dependencies in Android Applications Technical requirements Introduction to DI Using Dagger 2 to manage dependencies Using Hilt to manage dependencies Exercise 04.01 – Using Hilt to manage dependencies Summary Part 2 – Domain and Data Layers Chapter 5: Building the Domain of an Android Application Technical requirements Introducing the app's architecture Creating the domain layer Exercise 05.01 – Building a domain layer Summary Chapter 6: Assembling a Repository Technical requirements Creating the data layer Creating repositories Exercise 06.01 – Creating repositories Summary Chapter 7: Building Data Sources Technical requirements Building and using remote data sources Exercise 07.01 – Building a remote data source Building and integrating local data sources Exercise 07.02 – Building a local data source Summary Part 3 – Presentation Layer Chapter 8: Implementing an MVVM Architecture Technical requirements Presenting data in Android applications Presenting data with MVVM Exercise 08.01 – Implementing MVVM Presenting data in multiple modules Exercise 08.02 – Multi-module data presentation Summary Chapter 9: Implementing an MVI Architecture Technical requirements Introducing MVI Implementing MVI with Kotlin flows Exercise 09.01 – Transitioning to MVI Summary Chapter 10: Putting It All Together Technical requirements Inspecting module dependencies Exercise 10.01 – Reduce dependencies Instrumentation testing Exercise 10.02 – Instrumented testing Summary Why subscribe? Other Books You May Enjoy Packt is searching for authors like you
How to download source code?
1. Go to:
2. In the Find a repository… box, search the book title:
Clean Android Architecture: Take a layered approach to writing clean, testable, and decoupled Android applications, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.