【问题标题】:Android studio 3.0 error, how can I get rid of it?Android studio 3.0 报错,怎么解决?
【发布时间】:2017-10-31 11:37:27
【问题描述】:

我现在刚刚将我的 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'
}

有什么问题吗?

【问题讨论】:

  • 你能粘贴完整的堆栈跟踪吗
  • 我改为编译'com.google.android.support:wearable:2.0.0',并添加提供的'com.google.wearable.support:wearable:2.0.0',就可以了现在

标签: android android-studio android-gradle-plugin android-studio-3.0


【解决方案1】:

根据新的gradle dependency instruction compile 已被弃用,因此库使用api 并使用最新的稳定库版本2.1.0

而且由于该版本是稳定版本,所以

api 'com.google.android.support:wearable:2.1.0'

或者最好使用

implementation 'com.google.android.support:wearable:2.1.0'

implementation

如果一个实现依赖改变了它的 API,Gradle 会重新编译 只有那个依赖和直接依赖它的模块。最多 app 和 test 模块应该使用这个配置。

api

当一个模块包含一个 api 依赖时,它会让 Gradle 知道 该模块希望将该依赖项传递到其他 模块,以便它们在运行时和编译时都可用 时间。 This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library modules. That's because, if an api dependency changes its external API, Gradle recompiles all modules that have access to that dependency at compile time

【讨论】:

    猜你喜欢
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    相关资源
    最近更新 更多