问题
I just update my android studio to 3.0 now, but when I try to build apk on my project, it's shows following error:
Project depends on com.google.android.support:wearable:2.0.0, so it must also depend (as a provided dependency) on com.google.android.wearable:wearable:2.0.0
My build.gradle is like that:
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'
}
Anything wrong with it?
回答1:
As per the new gradle dependency instruction the compile
has been deprecated so for libraries use api
and use the latest stable lib version as 2.1.0
and since the version is a stable release so
api 'com.google.android.support:wearable:2.1.0'
or it's better to use
implementation 'com.google.android.support:wearable:2.1.0'
implementation
if an implementation dependency changes its API, Gradle recompiles only that dependency and the modules that directly depend on it. Most app and test modules should use this configuration.
api
When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time.
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
来源:https://stackoverflow.com/questions/47034454/android-studio-3-0-error-how-can-i-get-rid-of-it