android – Gradle错误:配置声明未声明的依赖项
作者:互联网
我正在制作我的第一个Android服装应用程序,但我无法让Android Studio工作.
首先我得到了错误
"Project with path ':wear' could not be found in project ':mobile'.
通过在settings.gradle中添加“include”:wear“解决了这个问题.
但随后出现了一个新错误:
"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" .
我该怎么做才能解决这个错误?
以防万一需要:这是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'
解决方法:
在Android Studio 3.0中,Migrate to the New Plugin的文档说:
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')
标签:android,android-studio,wear-os,gradle,dependencies 来源: https://codeday.me/bug/20190927/1822358.html