Gradle 错误:配置声明了未声明的依赖项 [英] Gradle error: configuration declares dependency which is not declared
本文介绍了Gradle 错误:配置声明了未声明的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作我的第一个 Android Wear 应用,但我无法让 Android Studio 运行.首先我得到了错误
I'm making my first android wear app, but I can't get Android Studio working. First I got the error
"Project with path ':wear' could not be found in project ':mobile'.
通过在 settings.gradle
中添加 "include ':wear"
解决了这个问题.
但随后出现新错误:
This was resolved by adding "include ':wear"
in settings.gradle
.
But then a new error occurs:
"Error:Module version Test2:mobile:unspecified, configuration 'wearApp' declares a dependency on configuration 'default' which is not declared in the module descriptor for Test2:wear:unspecified" .
我该怎么做才能解决这个错误?
What do I have to do to resolve that error?
以防万一:这里是build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.verbraeken.joost.test2"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:design:23.1.1'
}
settings.gradle:
settings.gradle:
include ':mobile'
include ':wear'
推荐答案
在 Android Studio 3.0 中 迁移到新插件 说:
In Android Studio 3.0 the documentation for Migrate to the New Plugin says:
dependencies {
// This is the old method and no longer works for local
// library modules:
// debugCompile project(path: ':foo', configuration: 'debug')
// releaseCompile project(path: ':foo', configuration: 'release')
// Instead, simply use the following to take advantage of
// variant-aware dependency resolution. You can learn more about
// the 'implementation' configuration in the section about
// new dependency configurations.
implementation project(':foo')
// You can, however, keep using variant-specific configurations when
// targeting external dependencies. The following line adds 'app-magic'
// as a dependency to only the 'debug' version of your module.
debugImplementation 'com.example.android:app-magic:12.3'
}
所以改变这个
debugCompile project(path: ':foo', configuration: 'debug')
releaseCompile project(path: ':foo', configuration: 'release')
到这里
implementation project(':foo')
这篇关于Gradle 错误:配置声明了未声明的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文