本文介绍了Gradle错误:配置声明未声明的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作我的第一款Android Wear应用,但我无法使用Android Studio工作。
首先我得到错误
带路径的项目:磨损'在项目中找不到':手机'。
通过添加include':wear
in settings.gradle
。
但是接着发生新的错误:
错误:模块版本Test2:mobile:未指定,配置'wearApp'声明对Test2模块描述符中未声明的配置'default'的依赖:wear:unspecified。
我需要做些什么来解决这个错误?
以防万一需要:这里是 build.gradle
:
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion23.0.2
defaultConfig {
applicationIdcom.verbraeken.joost.test2
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt' ),'proguard-rules.pro'
}
}
}
依赖项{
编译fileTree(dir:'libs',include:[ '* .jar'])
wearApp项目(':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:
包含':mobile'
include':wear'
解决方案
在Android Studio 3.0中,说:
依赖关系{
/ /这是旧方法,不再适用于本地
//库模块:
// debugCompile项目(路径:':foo',配置:'debug')
// releaseCompile项目(路径:':foo',配置:'release')
//相反,只需使用以下内容即可利用
//变体感知依赖关系解决方案。您可以在关于
//新依赖配置的部分中了解更多有关
//'实现'配置的信息。
实现项目(':foo')
//然而,当
//针对外部依赖关系时,您可以继续使用特定于变体的配置。以下行将'app-magic'
//作为依赖项添加到您的模块的调试版本。
debugImplementation'com.example.android:app-magic:12.3'
}
所以改变这个
debugCompile项目(路径:':foo',配置:'debug')
releaseCompile项目(路径:':foo',配置:'release')
执行项目(':foo')
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'.
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?
Just in case it's needed: here's 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:
include ':mobile'
include ':wear'
解决方案
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'
}
So change this
debugCompile project(path: ':foo', configuration: 'debug')
releaseCompile project(path: ':foo', configuration: 'release')
to this
implementation project(':foo')
这篇关于Gradle错误:配置声明未声明的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!