安卓工作室3.0错误,如何消除?

3

我刚刚将我的Android Studio升级到3.0,但当我尝试在我的项目上构建apk时,它显示以下错误:

该项目依赖于com.google.android.support:wearable:2.0.0,因此还必须依赖于com.google.android.wearable:wearable:2.0.0(作为提供的依赖项)

我的build.gradle如下:

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':lpd')
    compile 'com.google.android.support:wearable:2.0.0-alpha2'
    compile 'com.google.android.gms:play-services-wearable:9.4.0'
    compile files('libs/zxing_2.3.0.jar')
    compile(name: 'hwwearableservice-release', ext: 'aar')
    compile 'com.google.android.gms:play-services-appindexing:9.4.0'
}

这有什么问题吗?


你能粘贴完整的堆栈跟踪吗? - Yash
我改为编译'com.google.android.support:wearable:2.0.0',并添加了提供的'com.google.wearable.support:wearable:2.0.0',现在可以了。 - R.W
1个回答

4
根据新的Gradle依赖说明compile已被弃用,因此对于库,请使用api并使用最新的稳定库版本2.1.0。由于该版本是稳定版,因此...
api 'com.google.android.support:wearable:2.1.0'

或者最好使用。
implementation 'com.google.android.support:wearable:2.1.0'

实现

如果实现依赖项更改其API,则Gradle仅重新编译该依赖项以及直接依赖于它的模块。大多数应用程序和测试模块都应该使用此配置。

api

当一个模块包含一个api依赖项时,它让Gradle知道该模块想要传递地向其他模块导出该依赖项,以便在运行时和编译时都可以使用它。 这个配置的行为就像编译一样(现在已经被弃用),通常只应在库模块中使用。这是因为,如果api依赖项更改其外部API,则Gradle会重新编译所有可以访问该依赖项的模块。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接