How to get the latest Room version?

Viewed 5705

Would you know where to get the latest version for Room ?

On this Android Studio page, it is quoted that the latest Room version is 2.1.0-alpha3 but when I put this version in my build.gradle file, the project cannot compile and the following error is shown :

ERROR: Failed to resolve: android.arch.persistence.room:runtime:2.1.0-alpha3
Show in Project Structure dialog
Affected Modules: app
3 Answers

it is quoted that the latest Room version is 2.1.0-alpha3

It is.

when I put this version in my build.gradle file, the project cannot compile and the following error is shown

Your version is fine. Your artifact is the problem.

All new libraries are AndroidX. Your choices are:

  • Stick with whatever version you are using right now and keep your android.arch.persistence.room:runtime artifact and its classes, or

  • Migrate to AndroidX, in which case you would use androidx.room:room-runtime as the artifact, and need to change your code to reference the androidx classes for Room and everything else

The thing is, if you'r using AndroidX then the latest is 2.1.0-alpha3, or, if you are using Support libraries then it's 1.1.1 or whatever is latest and that's what mentioned in the documentation. As mentioned by CommonsWare, it's the artifact, and to find out the mappings, see this mapping documentation. And AndroidX is:

The AndroidX library contains the existing support library and also includes the latest Jetpack components.

Example using support libraries:

dependencies {
    // Other libraries...
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
}

The solution is to check AndroidX when starting a new project in Android Studio, then in the App Module Build.Gradle file the following works perfectly :

def room_version = "2.1.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" // use kapt for Kotlin
Related