1dependencies {
2 def lifecycle_version = "2.2.0"
3 def arch_version = "2.1.0"
4
5 // ViewModel
6 implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
7 // LiveData
8 implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
9 // Lifecycles only (without ViewModel or LiveData)
10 implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
11
12 // Saved state module for ViewModel
13 implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
14
15 // Annotation processor
16 annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
17 // alternately - if using Java8, use the following instead of lifecycle-compiler
18 implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
19
20 // optional - helpers for implementing LifecycleOwner in a Service
21 implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
22
23 // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process
24 implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
25
26 // optional - ReactiveStreams support for LiveData
27 implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version"
28
29 // optional - Test helpers for LiveData
30 testImplementation "androidx.arch.core:core-testing:$arch_version"
31}
32
1// ViewModel and LiveData
2implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
3// alternatively - just ViewModel
4implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // For Kotlin use lifecycle-viewmodel-ktx
5// alternatively - just LiveData
6implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
7// alternatively - Lifecycles only (no ViewModel or LiveData). Some UI
8// AndroidX libraries use this lightweight import for Lifecycle
9implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
10
11annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
12// alternately - if using Java8, use the following instead of lifecycle-compiler
13implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
14
15// optional - ReactiveStreams support for LiveData
16implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // For Kotlin use lifecycle-reactivestreams-ktx
17
18// optional - Test helpers for LiveData
19testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
20