Android Studio 3.0导入module Gradle builde报错
Unable to resolve dependency for ':@repositories/compileClasspath': Could not resolve project :lib-permission.
Could not resolve project :lib-permission.
Required by:
project :
> Unable to find a matching configuration of project :lib-permission:
- Configuration 'debugApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'repositories' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'repositories' and found incompatible value 'debug'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
- Configuration 'releaseApiElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'repositories' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'repositories' and found incompatible value 'release'.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
app中buildTypes集合不是library的buildTypes集合子集,即app中buildType属性preview在依赖的library中找不到。
背景:
build.gradle(module:library):
apply plugin: 'com.android.library'
android {
buildTypes {
release {
...
}
debug{
...
}
}
}
build.gradle(module:app):
apply plugin: 'com.android.application'
//或
//apply plugin: 'com.android.library'
android {
buildTypes {
release {
...
}
preview {
...
}
debug {
...
}
}
}
dependencies {
compile project(':library')
}
解决办法:
把 所有library的buildType修改为和app模块一致就行。