> Documentation index: https://developer.android.com/courses/llms.txt

# Architecture Components


Learn about app architecture and how to use ViewModels, UI State, and StateFlow to build more complex apps.  


Go back

## Welcome to Unit 4

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Video *Optional*

Welcome to Unit 4! This unit covers important topics for you to consider when building apps that have more logic and more screens. The unit includes: app architecture, navigation between different screens in an app, and adaptive layouts.

<button class="playlist-skip gc-analytics-event" data-category="devsite-playlist: skip button"> Skip </button>

## Stages of the Activity lifecycle

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Codelab

In this codelab, you learn about the Activity lifecycle and logging.

[Take codelab](https://developer.android.com/codelabs/basic-android-kotlin-compose-activity-lifecycle)

## Intro to App architecture

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Video *Optional*

Learn how to architect Android apps using design patterns, techniques, and best practices for Android app development.

<button class="playlist-skip gc-analytics-event" data-category="devsite-playlist: skip button"> Skip </button>

## Architecture: The UI Layer

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Video *Optional*

In this video, you'll learn about the UI layer and how to use unidirectional data flow to handle UI state.

<button class="playlist-skip gc-analytics-event" data-category="devsite-playlist: skip button"> Skip </button>

## ViewModel and State in Compose

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Codelab

In this codelab, you learn how to use a ViewModel, one of the architecture components. You will implement a ViewModel to retain the app state during configuration changes.

[Take codelab](https://developer.android.com/codelabs/basic-android-kotlin-compose-viewmodel-and-state)

## Write unit tests to test the ViewModel

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Codelab

Learn how to test the ViewModel to verify the correctness, functional behavior, and usability of your app.

[Take codelab](https://developer.android.com/codelabs/basic-android-kotlin-compose-test-viewmodel)

## Practice: Add a ViewModel to Dessert Clicker

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Codelab

Practice adding a ViewModel to an app and abstracting logic away from the Activity.

[Take codelab](https://developer.android.com/codelabs/basic-android-kotlin-compose-practice-viewmodel)

## What's next?

<button class="toggle gc-analytics-event" data-category="devsite-playlist: toggle button"> *keyboard_arrow_down* *keyboard_arrow_up* </button> Video *Optional*

Congratulations on completing Pathway 1 in Unit 4! You have progressed amazingly in your app development journey. In this pathway you built both the Dessert Clicker and Unscramble apps and along the way you learned about the app lifecycle, handling configuration changes, and app architecture.

<button class="playlist-skip gc-analytics-event" data-category="devsite-playlist: skip button"> Skip </button>

## Quiz

Test your knowledge and earn your Architecture Components badge.
[Take the quiz](https://developer.android.com/courses/quizzes/android-basics-compose-unit-4-pathway-1/android-basics-compose-unit-4-pathway-1.md.txt)