我有問題將我的項目遷移到最新的Gradle 4.0 + Android Studio 3版本,這給我帶來了各種各樣的錯誤。我一點一點地設法排除他們,除了這一個。Android Studio 3 + Gradle 4.0 + shrinkResources + libraryProject =無法在項目中找到匹配的配置
Could not resolve all dependencies for configuration ':app:forGoogleCoverageRuntimeClasspath'.
> Unable to find a matching configuration in project :mylibrary:
- Configuration 'debugApiElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=debug}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
- Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided.
- Configuration 'debugRuntimeElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=debug}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.
- Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided.
- Configuration 'releaseApiElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=release}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found incompatible value 'for compile'.
- Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' and found compatible value 'AndroidTypeAttr{name=Aar}'.
- Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=coverage}' and found incompatible value 'BuildTypeAttr{name=release}'.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required.
- Required org.gradle.api.attributes.Usage 'for runtime' and found compatible value 'for runtime'.
- Required store 'ProductFlavorAttr{name=forGoogle}' but no value provided.
爲了明確該問題:
- 我已經從Android的工作室項目助理創建了最低的應用項目,
- 添加一個空庫模塊,然後我添加到我的應用程序依賴。
- 加入一個flavorDimensions和2個productFlavors
- 加入3-構建類型,並讓一個生成類型從另一個
- 繼承讓繼承生成類型啓用
shrinkResources
最後一步產生提到的錯誤,這與此問題類似: Gradle 4.0 Unable to find a matching configuration
有沒有人知道這裏有什麼問題或解決這個問題?我也會提交一個錯誤報告。
我的gradle完整文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "gradletest.test"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
flavorDimensions "store"
productFlavors {
forAmazon {
dimension "store"
}
forGoogle {
dimension "store"
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
}
release {
minifyEnabled true
debuggable false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
coverage.initWith(buildTypes.debug)
coverage {
testCoverageEnabled true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
implementation project(':mylibrary')
}
錯誤報告相關的解決構建錯誤:HTTPS:/ /issuetracker.google.com/issues/62170415隨時恭維。現在它幫助我從我的構建類型中移除shrinkResources – JimmyVanBraun