Adding Components to your Project

Before getting started, we recommend reading the Architecture Components Guide to App Architecture. The guide has some useful principles that apply to all Android apps, and shows how to use the Architecture Components together.

Architecture Components are available from Google's Maven repository. To use them, follow these steps:

Add the Google Maven repository

Android Studio projects aren't configured to access this repository by default.

To add it to your project, open the build.gradle file for your project (not the ones for your app or module) and add the google() repository as shown below:

allprojects {
    repositories {

Add Architecture Components

Open the build.gradle file for your app or module and add the artifacts that you need as dependencies. You can add all dependencies, or choose a subset.

Note: For Kotlin based apps, make sure you use kapt instead of annotationProcessor. You should also add the kotlin-kapt plugin.

Main Dependencies

Includes Lifecycles, LiveData, ViewModel, Room, and Paging.

It also includes test helpers for testing LiveData as well as testing Room migrations.

dependencies {
    // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:1.1.1"
    // alternatively, just ViewModel
    implementation "android.arch.lifecycle:viewmodel:1.1.1"
    // alternatively, just LiveData
    implementation "android.arch.lifecycle:livedata:1.1.1"

    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

    // Room (use 1.1.0-beta3 for latest beta)
    implementation ""
    annotationProcessor ""

    // Paging
    implementation "android.arch.paging:runtime:1.0.0-rc1"

    // Test helpers for LiveData
    testImplementation "android.arch.core:core-testing:1.1.1"

    // Test helpers for Room
    testImplementation ""
Java 8 Support for Lifecycles

If your app uses Java 8, we recommend using this library instead of android.arch.lifecycle:compiler.

dependencies {
    // Java8 support for Lifecycles
    implementation "android.arch.lifecycle:common-java8:1.1.1"
Optional Dependencies for RxJava and ReactiveStreams

Adds optional support for Room RxJava and LiveData ReactiveStreams.

dependencies {
    // RxJava support for Room (use 1.1.0-beta3 for latest beta)
    implementation ""

    // ReactiveStreams support for LiveData
    implementation "android.arch.lifecycle:reactivestreams:1.1.1"

    // RxJava support for Paging
    implementation "android.arch.paging:rxjava2:1.0.0-alpha1"
Optional Dependencies for Guava

Adds support for Guava's Optional and ListenableFuture types in Room @Dao queries.

dependencies {
    // Guava support for Room
    implementation ""
Alternative import for lightweight Lifecycles only

Support library depends on this lightweight import. It provides Lifecycles without LiveData or ViewModel.

dependencies {
    // Lifecycles only (no ViewModel or LiveData)
    implementation "android.arch.lifecycle:runtime:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

For more information, see Add Build Dependencies.