Kickstart Modern Android Development with Jetpack and Kotlin: Enhance your applications by integrating Jetpack and applying modern app architectural concepts

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Explore modern Android development in Kotlin 1.6.10 with this condensed hands-on guide to building reliable apps using libraries such as Compose, ViewModel, Hilt, Retrofit, Flow, and more

Key Features

  • Explore Jetpack libraries and other modern technologies for Android development
  • Improve the architectural design of your Android apps
  • Enhance the quality of your Android projects' code bases and applications using the latest libraries

Book Description

With Jetpack libraries, you can build and design high-quality, robust Android apps that have an improved architecture and work consistently across different versions and devices. This book will help you understand how Jetpack allows developers to follow best practices and architectural patterns when building Android apps while also eliminating boilerplate code.

Developers working with Android and Kotlin will be able to put their knowledge to work with this condensed practical guide to building apps with the most popular Jetpack libraries, including Jetpack Compose, ViewModel, Hilt, Room, Paging, Lifecycle, and Navigation. You'll get to grips with relevant libraries and architectural patterns, including popular libraries in the Android ecosystem such as Retrofit, Coroutines, and Flow while building modern applications with real-world data.

By the end of this Android app development book, you'll have learned how to leverage Jetpack libraries and your knowledge of architectural concepts for building, designing, and testing robust Android applications for various use cases.

What you will learn

  • Integrate popular Jetpack libraries such as Compose, ViewModel, Hilt, and Navigation into real Android apps with Kotlin
  • Apply modern app architecture concepts such as MVVM, dependency injection, and clean architecture
  • Explore Android libraries such as Retrofit, Coroutines, and Flow
  • Integrate Compose with the rest of the Jetpack libraries or other popular Android libraries
  • Work with other Jetpack libraries such as Paging and Room while integrating a real REST API that supports pagination
  • Test Compose UI and the application logic through unit tests

Who this book is for

This book is for junior and intermediate-level Android developers looking to level up their Android development skills to develop high-quality apps using Jetpack libraries and other cutting-edge technologies. Beginners with knowledge of Android development fundamentals will also find this book useful. Familiarity with Kotlin is assumed.

Table of Contents

  1. Creating Modern UIs with Jetpack Compose
  2. Handling UI state with Jetpack ViewModel
  3. Displaying Real Data from a REST API with Retrofit
  4. Handling Async Operations with Coroutines
  5. Adding Navigation in Compose with Jetpack Navigation
  6. Adding Offline Capabilities with Jetpack Room
  7. Introducing Presentation Patterns in Android
  8. Getting Started with Clean Architecture in Android
  9. Implementing Dependency Injection with Jetpack Hilt
  10. Test your app with UI and Unit tests
  11. Creating Infinite Lists with Jetpack Paging and Kotlin Flow
  12. Exploring the Jetpack Lifecycle Components

Author(s): Catalin Ghita
Edition: 1
Publisher: Packt Publishing
Year: 2022

Language: English
Pages: 472
Tags: Android Development; Android SDK; Kotlin; Android Jetpack

Cover
Title Page
Dedicated
Contributors
Table of Contents
Preface
Copyright and Credits
Part 1: Exploring the Core Jetpack Suite and Other Libraries
Chapter 1: Creating a Modern UI with Jetpack Compose
Technical requirements
Understanding the core concepts of Compose
Describing UIs with composable functions
The paradigm shift in creating UIs on Android
Favoring composition over inheritance
Unidirectional flow of data
Recomposition
Exploring the building blocks of Compose UIs
Setting content and previewing composables
Exploring core composables
Customizing composables with modifiers
Layouts in Compose
Building a Compose-based screen
Creating your first Compose project
Building a restaurant element layout
Displaying a list of restaurants with Compose
Exploring lists with Compose
Adding scrolling to the Column composable
Introducing lazy composables
Using LazyColumn to display restaurants
Summary
Further reading
Chapter 2: Handling UI State with Jetpack ViewModel
Technical requirements
Understanding the Jetpack ViewModel
What is a ViewModel?
Why do you need ViewModels?
Introducing Android Jetpack ViewModel
Implementing your first ViewModel
Defining and handling state with Compose
Understanding state and events
Adding state to our Restaurants app
Hoisting state in Compose
Recovering from system-initiated process death
Summary
Further reading
Exploring ViewModel with runtime-provided arguments
Exploring ViewModel for Kotlin Multiplatform projects
Understanding how to minimize the number of recompositions
Chapter 3: Displaying Data from REST APIs with Retrofit
Technical requirements
Understanding how apps communicate with remote servers
Creating and populating your database with Firebase
Exploring Retrofit as an HTTP networking client for Android
Using Retrofit
Adding Retrofit to the Restaurants application
Mapping JSON to model classes
Executing GET requests to the Firebase REST API
Improving the way our app handles network requests
Summary
Further reading
Chapter 4: Handling Async Operations with Coroutines
Technical requirements
Introducing Kotlin coroutines
What is a coroutine?
The features and advantages of coroutines
How do coroutines work?
Exploring the basic elements of coroutines
Creating suspending functions
Launching coroutines
Using coroutines for async work
Implementing coroutines instead of callbacks
Improving the way our app works with coroutines
Summary
Further reading
Chapter 5: Adding Navigation in Compose With Jetpack Navigation
Technical requirements
Introducing the Jetpack Navigation component
Creating a new Compose-based screen
Defining the HTTP request for the contents of a restaurant
Getting the contents of a specific restaurant
Building the restaurant details screen
Implementing navigation with Jetpack Navigation
Adding support for deep links
Summary
Part 2: A Guide to Clean Application Architecture with Jetpack Libraries
Chapter 6: Adding Offline Capabilities with Jetpack Room
Technical requirements
Introducing Jetpack Room
Exploring the caching mechanism on Android
Introducing Jetpack Room as a solution for local caching
Enabling offline usage by implementing Room
Applying partial updates to the Room database
Making local data the single source of truth for app content
Refactoring the Restaurants app to have a single source of truth for data
Removing the logic of persisting state in the case of process recreation
Summary
Chapter 7: Introducing Presentation Patterns in Android
Technical requirements
Introducing MVC, MVP, and MVVM as presentation patterns
MVC
MVP
MVVM
Refactoring our Restaurants app to fit a presentation pattern
Adding more functionality inside our Restaurants app
Refactoring our Restaurants app to MVVM
Improving state encapsulation in ViewModel
Summary
Chapter 8: Getting Started with Clean Architecture in Android
Technical requirements
Defining the Domain layer with Use Cases
Separating the Domain model from Data models
Creating a package structure
Decoupling the Compose-based UI layer from ViewModel
Summary
Further reading
Chapter 9: Implementing Dependency Injection with Jetpack Hilt
Technical requirements
What is DI?
Why is DI needed?
Write less boilerplate code
Write testable classes
Implementing DI with Hilt
Understanding the basics of Dagger Hilt
Setting up Hilt
Using Hilt for DI
Summary
Further reading
Chapter 10: Test Your App with UI and Unit Tests
Technical requirements
Exploring the fundamentals of testing
Understanding the benefits of testing
Exploring types of tests
Learning the basics of testing your Compose UI
Covering the basics of unit-testing your core logic
Testing the functionality of a ViewModel class
Testing the functionality of a UseCase class
Summary
Further reading
Part 3: Diving into Other Jetpack Libraries
Chapter 11: Creating Infinite Lists with Jetpack Paging and Kotlin Flow
Technical requirements
Why do we need pagination?
Importing and exploring the Repositories App
Using Kotlin Flow to handle streams of data
Exploring pagination with Jetpack Paging
Implementing pagination with Jetpack Paging
Implementing loading and error states plus retry functionality
Summary
Further reading
Chapter 12: Exploring the Jetpack Lifecycle Components
Technical requirements
Introducing the Jetpack Lifecycle components
ViewModel
LiveData
Adding a countdown component in the Repositories app
Creating your own lifecycle-aware component
Making our countdown component aware of the lifecycle of composables
Summary
Further reading
Index
Other Books You May Enjoy