我正在尝试将android Room库添加到我的项目中,但是我不能。
我按照开发站点上的说明进行操作,但是没有用。
构建文件(项目):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
构建文件(应用程序):
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:recyclerview-v7:25.3.1'
implementation 'com.android.support:design:25.3.1'
def room_version = "1.1.0"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
implementation "android.arch.persistence.room:rxjava2:$room_version"
implementation "android.arch.persistence.room:guava:$room_version"
testImplementation "android.arch.persistence.room:testing:$room_version"}
然后当我同步项目时。
我看到此错误:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve android.arch.persistence.room:runtime:1.1.0.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve android.arch.persistence.room:rxjava2:1.1.0.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve android.arch.persistence.room:guava:1.1.0.
Failed to resolve: android.arch.persistence.room:rxjava2:1.1.0
Failed to resolve: android.arch.persistence.room:guava:1.1.0
Failed to resolve: android.arch.persistence.room:runtime:1.1.0
当我检查jcenter.bintray.com时出现404错误。 我该怎么办?
谢谢
答案 0 :(得分:1)
尝试将maven { url 'https://maven.google.com' }
添加到build.gradle文件(项目)中的存储库列表中:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}