无法解决:android.arch.persistance.room:testing:1.1.1

时间:2018-07-09 16:43:33

标签: android android-studio

我正在尝试使用Architecture Components Room和Lifecycles库在Android Studio中制作一个应用,但是当我对其进行同步时,它会给我一个错误Failed to resolve: android.arch.persistance.room:testing:1.1.1

我在应用build.gradle中的代码是:

implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
androidTestImplementation "android.arch.persistance.room:testing:$rootProject.roomVersion"

implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
annotationProcessor "android.arch.lifestyle:compiler:$rootProject.archLifecycleVersion"

整个项目级别build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext {
    roomVersion = '1.1.1'
    archLifecycleVersion = '1.1.1'
}

1 个答案:

答案 0 :(得分:1)

  

无法解决:android.arch.persistance.room:testing:1.1.1

打开项目的 build.gradle 文件(而不是应用程序或模块的文件),并添加 google() 存储库,如下所示:

allprojects {
    repositories {
        jcenter()
        google()

    }
}

您应该使用 gradle:3.1.3

dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
       }

通过Internet更改 Clean-Rebuild and SYNC 后。

注意

您应该设置 lifecycle ,而不是 生活方式

annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"