Skip to content

Instantly share code, notes, and snippets.

@sanogueralorenzo
Created March 22, 2018 21:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sanogueralorenzo/217ab91e45b2b66935608bb6f48c0d1f to your computer and use it in GitHub Desktop.
Save sanogueralorenzo/217ab91e45b2b66935608bb6f48c0d1f to your computer and use it in GitHub Desktop.
ViewModel & LiveData dependencies
dependencies {
//Other dependencies...
implementation "android.arch.lifecycle:extensions:1.1.0"
annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
testImplementation "android.arch.core:core-testing:1.1.0"
}
@IhwanID
Copy link

IhwanID commented Aug 16, 2019

dependencies {
def lifecycle_version = "2.0.0"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// alternatively - just ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // For Kotlin use lifecycle-viewmodel-ktx
// alternatively - just LiveData
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
// alternatively - Lifecycles only (no ViewModel or LiveData). Some UI
//     AndroidX libraries use this lightweight import for Lifecycle
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"

annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

// optional - ReactiveStreams support for LiveData
implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // For Kotlin use lifecycle-reactivestreams-ktx

// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment