Joo*_*ken 22 dependencies android gradle android-studio wear-os
我正在制作我的第一个Android服装应用程序,但我无法让Android Studio工作.首先我得到了错误
"Project with path ':wear' could not be found in project ':mobile'.
Run Code Online (Sandbox Code Playgroud)
这是通过添加"include ':wear"
来解决的settings.gradle
.
但随后出现了一个新错误:
"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" .
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决这个错误?
以防万一需要:这里是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'
}
Run Code Online (Sandbox Code Playgroud)
settings.gradle:
include ':mobile'
include ':wear'
Run Code Online (Sandbox Code Playgroud)
Jon*_*ren 48
在Android Studio 3.0中,迁移到新插件的文档说:
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'
}
Run Code Online (Sandbox Code Playgroud)
所以改变这个
debugCompile project(path: ':foo', configuration: 'debug')
releaseCompile project(path: ':foo', configuration: 'release')
Run Code Online (Sandbox Code Playgroud)
对此
implementation project(':foo')
Run Code Online (Sandbox Code Playgroud)
错误:模块版本Test2:mobile:未指定,配置'wearApp'声明对配置'default'的依赖
这意味着模块(在您的情况下为wearApp)在build.gradle
文件中没有文件或正确的配置build.gradle
.
由于您定义了一个模块,settings.gradle
您必须build.gradle
为每个模块提供一个模块.
在你的情况下:
root
|-- mobile
|----build.gradle
|-- wear
|----build.gradle
|--build.gradle
|--settings.gradle
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
39739 次 |
最近记录: |