Android:标准建议的依赖项给出 Gradle 同步错误。解析失败:com.android.support:wear:24.0.0

Android: Standard suggested dependencies give Gradle sync error. Failed to resolve: com.android.support:wear:24.0.0

我正在开发一款同时适用于移动设备和穿戴设备的音乐应用程序。我已经完成了移动应用程序的基础构建,现在我想开始可穿戴 (2.0) 部分。我尝试遵循 tutorial on the Android Developer site,但即使遵循基本说明也会出现 Gradle 同步错误。我尝试将 compileSdkVersion 和 targetSdkVersion 都调整为 24,我将其用于我的手机 gradle scrip。然而,这并没有什么不同。

这是提到的指令:

In the build.gradle file for the Wear module:
>> In the android section, confirm that the compileSdkVersion is set to 25.

>> In the android section, confirm that the targetSdkVersion is set to 25.
Update the dependencies section as follows (requires the latest version of the Google Repository):  
compile 'com.android.support:wear:26.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'

点击 "install repository and sync project" 无效。

这是 Wear 模块的 build.gradle 文件。

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:wear:24.0.0'
    compile 'com.google.android.support:wearable:2.0.3'
    provided 'com.google.android.wearable:wearable:2.0.3'
}

我是 Android 的新手,我不太明白这里出了什么问题。感谢您提供任何帮助,即使它不能直接解决问题![​​=17=]

将您的 gradle 更改为:

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:wear:26.0.0'
    compile 'com.google.android.support:wearable:2.0.3'
    provided 'com.google.android.wearable:wearable:2.0.3'
}

编辑:经过反复试验,终于找到解决方案:

build.gradle 文件中 -> allprojects,在 repositories,代码中下面应该加上...

1) 对于 Android Gradle 插件版本 2.3.3 和 Gradle 3.3 (Android Studio 2.3.3)

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

2) 对于 Android Gradle 插件修订版 3.0.0 Gradle 4.1(Android Studio 3.0.0)

allprojects {
    repositories {
        jcenter()
        google()
    }
}

更多信息请点击此处: