How to import Room Persistence Library to an Android project

Francisco Durdin Garcia picture Francisco Durdin Garcia · May 18, 2017 · Viewed 38k times · Source

I recently saw the new feature announced on Google I/O Room Persistence Library to work with Sqlite databases on Android. I have been looking to the official documentation and I don't find which dependencies I should import to my gradle file on my Android project. Someone can give me a hand?

Answer

Francisco Durdin Garcia picture Francisco Durdin Garcia · May 18, 2017

It's possible to find the dependencies on the example codelab for the new architecture components.

Root :

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

For Room:

  implementation 'android.arch.persistence.room:runtime:1.0.0-alpha1'
  annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha1'

For Lifecycle dependencies:

  implementation 'android.arch.lifecycle:extensions:1.0.0-alpha1'
  annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-alpha1'

Adding Rxjava2 objects as result for our queries:

  implementation 'android.arch.persistence.room:rxjava2:1.0.0-alpha1'

Test migrations:

  testImplementation'android.arch.persistence.room:testing:1.0.0-alpha1'