Error:Failed to resolve: wearable

Error:Failed to resolve: wearable

我有一个现有项目,当我尝试向其中添加 wear 模块时,显示以下错误。当我使用 wear 模块创建一个新项目时,它正在运行。

Error:Failed to resolve: wearable

project depends of com.google.android.support:wearable:2.3.0 so it must also depend com.google.android.wearable:wearable:2.3.0

错误截图

您需要添加这样的提供

...
provided 'com.google.android.wearable:wearable:2.3.0'
implementation 'com.google.android.support:wearable:2.3.0'
...

还要检查您的项目级别 build.gradle 是否具有 google 存储库,我认为一些可穿戴库现在来自 google 而不是 jcenter。

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:deprecation"
    }
}