Clean Android Architecture

Book description

Learn how to build, maintain, and test Android applications using clean architecture principles

Key Features

  • 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

Book Description

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.

Table of contents

  1. Clean Android Architecture
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Code in Action
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Share Your Thoughts
  6. Part 1 – Introduction
  7. Chapter 1: Getting Started with Clean Architecture
    1. Technical requirements
    2. The architecture of a legacy app
      1. Legacy analysis
    3. Software design principles
      1. SOLID principles
      2. Component cohesion principles
      3. Component coupling principles
    4. Exploring the evolution of Android
      1. Fragments
      2. The Gradle build system
      3. Networking
      4. Humble objects
      5. Functional paradigms
      6. Kotlin adoption
      7. Dependency injection
      8. Android architecture components
      9. Coroutines and flows
      10. Jetpack Compose
    5. Enter clean architecture
    6. Summary
  8. Chapter 2: Deep Diving into Data Sources
    1. Technical requirements
    2. Understanding Kotlin coroutines and Flows
      1. Kotlin coroutines
      2. Exercise 02.01 – Using Kotlin coroutines
      3. Kotlin Flows
      4. Exercise 02.02 – Using Kotlin Flows
    3. Using OkHttp and Retrofit for networking
      1. Exercise 02.03 – Using OkHttp and Retrofit
    4. Using the Room library for data persistence
      1. Exercise 02.04 – Using Room to persist data
    5. Understanding and using the DataStore library
      1. Exercise 02.05 – Using DataStore to persist data
    6. Summary
  9. Chapter 3: Understanding Data Presentation on Android
    1. Technical requirements
    2. Analyzing lifecycle-aware components
      1. Exercise 3.1 – Using ViewModel and LiveData
    3. Using Jetpack Compose to build UIs
      1. Exercise 3.2 – Navigating using Jetpack Compose
    4. Summary
  10. Chapter 4: Managing Dependencies in Android Applications
    1. Technical requirements
    2. Introduction to DI
    3. Using Dagger 2 to manage dependencies
    4. Using Hilt to manage dependencies
      1. Exercise 04.01 – Using Hilt to manage dependencies
    5. Summary
  11. Part 2 – Domain and Data Layers
  12. Chapter 5: Building the Domain of an Android Application
    1. Technical requirements
    2. Introducing the app's architecture
    3. Creating the domain layer
      1. Exercise 05.01 – Building a domain layer
    4. Summary
  13. Chapter 6: Assembling a Repository
    1. Technical requirements
    2. Creating the data layer
    3. Creating repositories
      1. Exercise 06.01 – Creating repositories
    4. Summary
  14. Chapter 7: Building Data Sources
    1. Technical requirements
    2. Building and using remote data sources
      1. Exercise 07.01 – Building a remote data source
    3. Building and integrating local data sources
      1. Exercise 07.02 – Building a local data source
    4. Summary
  15. Part 3 – Presentation Layer
  16. Chapter 8: Implementing an MVVM Architecture
    1. Technical requirements
    2. Presenting data in Android applications
    3. Presenting data with MVVM
      1. Exercise 08.01 – Implementing MVVM
    4. Presenting data in multiple modules
      1. Exercise 08.02 – Multi-module data presentation
    5. Summary
  17. Chapter 9: Implementing an MVI Architecture
    1. Technical requirements
    2. Introducing MVI
    3. Implementing MVI with Kotlin flows
      1. Exercise 09.01 – Transitioning to MVI
    4. Summary
  18. Chapter 10: Putting It All Together
    1. Technical requirements
    2. Inspecting module dependencies
      1. Exercise 10.01 – Reduce dependencies
    3. Instrumentation testing
      1. Exercise 10.02 – Instrumented testing
    4. Summary
    5. Why subscribe?
  19. Other Books You May Enjoy
    1. Packt is searching for authors like you

Product information

  • Title: Clean Android Architecture
  • Author(s): Alexandru Dumbravan
  • Release date: June 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803234588