AndroidStudio 3.0: Error:Unable to resolve dependency for ':app@dev/compileClasspath': Could not resolve project :common
AndroidStudio 3.0: Error:Unable to resolve dependency for ':app@dev/compileClasspath': Could not resolve project :common
Android Studio 3.0
我有 3 种构建类型:
“release”和“dev”
project/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle
include ':app', ':common'
app/build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
kapt "com.github.bumptech.glide:compiler:$GLIDE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile project(':common')
}
但是当我尝试构建时出现下一个错误:
Unable to resolve dependency for ':app@dev/compileClasspath': Could not resolve project :common.
Could not resolve project :common.
Required by:
project :app
> Unable to find a matching configuration of project :common:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'dev' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
P.S。在 Android Studio 2.3.3 我的项目成功构建并且 运行
似乎是 Gradle 构建过程中的错误,尝试更改:
android {
buildTypes {
release {
...
}
dexOptions {
...
// release & debug is in project animators
}
dev {
matchingFallbacks = ["debug"]
}
}
}
dependencies {
'implementation project(':common')
}
此问题可能是由于模块 build.gradle
文件
之间未匹配 buildTypes
引起的
应用build.gradle
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dev {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
常见build.gradle[不正确]
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
// miss debug and dev config block (the reason of this problem)
}
}
一般build.gradle[正确]
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dev {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Android Studio 3.0
我有 3 种构建类型: “release”和“dev”
project/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
settings.gradle
include ':app', ':common'
app/build.gradle
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
kapt "com.github.bumptech.glide:compiler:$GLIDE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile project(':common')
}
但是当我尝试构建时出现下一个错误:
Unable to resolve dependency for ':app@dev/compileClasspath': Could not resolve project :common.
Could not resolve project :common.
Required by:
project :app
> Unable to find a matching configuration of project :common:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'dev' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
P.S。在 Android Studio 2.3.3 我的项目成功构建并且 运行
似乎是 Gradle 构建过程中的错误,尝试更改:
android {
buildTypes {
release {
...
}
dexOptions {
...
// release & debug is in project animators
}
dev {
matchingFallbacks = ["debug"]
}
}
}
dependencies {
'implementation project(':common')
}
此问题可能是由于模块 build.gradle
文件
buildTypes
引起的
应用build.gradle
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dev {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
常见build.gradle[不正确]
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
// miss debug and dev config block (the reason of this problem)
}
}
一般build.gradle[正确]
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dev {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}