提问者:小点点

如何在android项目中使用Room


我想要在我的应用程序中使用空间,我添加了这个依赖项:

    implementation 'android.arch.persistence.room:runtime:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'

google()

但当单击run按钮时,在下面显示错误消息:

Could not find compiler.jar (android.arch.persistence.room:compiler:1.1.1).
Searched in the following locations:
    https://dl.google.com/dl/android/maven2/android/arch/persistence/room/compiler/1.1.1/compiler-1.1.1.jar

我该怎么修好呢?


共2个答案

匿名用户

你必须在build.gradle文件中添加dependenci?

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

匿名用户

您是否将Google Maven存储库添加到您的项目中? 您应该在顶级build.gradle文件中添加Google的Maven存储库,如下所示:

allprojects {
    repositories {
        google()
    }
}

资料来源:

https://developer.android.com/studio/build/dependencies#谷歌-Maven https://developer.android.com/jetpack/androidx/releases/room#声明_dependencies