Android:标准建议的依赖项会产生Gradle同步错误。无法解决:com.android.support:wear:24.0.0

时间:2017-08-05 16:19:21

标签: android android-gradle build.gradle wear-os

我正在为移动设备开发音乐应用程序。穿。我已经完成了在移动设备上构建应用程序的基础,现在我想启动可穿戴(2.0)部分。我尝试按照tutorial on the Android Developer site进行操作,但即使按照基本说明操作也会出现Gradle同步错误。我尝试将compileSdkVersion和targetSdkVersion都调整为24,我将其用于移动gradle脚本。然而,它并没有什么不同。

这是提到的指示:

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'

This is the error generated

点击"安装存储库并同步项目"没有效果。

这是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很陌生,我真的不明白这里出了什么问题。任何帮助都表示赞赏,即使它不能直接解决问题!

2 个答案:

答案 0 :(得分:1)

编辑:试错后,终于找到了解决方案:

build.gradle 文件中 - > 所有项目,在存储库中,应添加以下代码...

1)对于使用Gradle 3.3(Android Studio 2.3.3)的Android Gradle插件版本2.3.3

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

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

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

有关详情,请访问:When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0

答案 1 :(得分:0)

将您的助手改为:

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'
}