Аромат ошибки градиента – Android Studio 3.0 Canary 1

Я хотел бы обновить свой проект до Android Studio 3.0 Canary 1 и плагина gradle: 3.0.0-alpha1, однако у меня есть проблема с правильным определением вкусов для включенных проектов.

Я следил за официальным руководством по миграции от Google: https://developer.android.com/studio/preview/features/new-android-plugin-migration.html

В моем основном приложении build.gradle я определил «myflavor» flavorDimensions , как рекомендовано в руководстве по миграции:

android { flavorDimensions "myflavor" productFlavors { dev { dimension "myflavor" minSdkVersion 21 } prod { dimension "myflavor" minSdkVersion 16 } } buildTypes { debug { signingConfig signingConfigs.debug } release { debuggable false signingConfig signingConfigs.release minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dependencies { compile project(':util') } 

В моем включенном модуле util (продюсер) я попытался включить его с определением flavorDimensions, productFlavors и buildTypes. Я получаю следующую ошибку градиента:

 Error:Could not resolve all dependencies for configuration ':app:prodDebugCompileClasspath'. Cannot choose between the following configurations on project :util: - debugApiElements - releaseApiElements All of them match the consumer attributes: - Configuration 'debugApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=debug}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. - Configuration 'releaseApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=release}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=release}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. 

При определении тех же самых параметров вкуса, productFlavors и buildTypes в: util, как и в основном приложении, появляется следующее сообщение об ошибке:

 Error:Could not resolve all dependencies for configuration ':app:prodDebugCompileClasspath'. Cannot choose between the following configurations on project :util: - devDebugApiElements - devReleaseApiElements - prodDebugApiElements - prodReleaseApiElements All of them match the consumer attributes: - Configuration 'devDebugApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=devDebug}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Found myflavor 'ProductFlavorAttr{name=dev}' but wasn't required. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. - Configuration 'devReleaseApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=release}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=devRelease}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Found myflavor 'ProductFlavorAttr{name=dev}' but wasn't required. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. - Configuration 'prodDebugApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=prodDebug}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Found myflavor 'ProductFlavorAttr{name=prod}' but wasn't required. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. - Configuration 'prodReleaseApiElements': - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but no value provided. - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'AndroidTypeAttr{name=Aar}' but wasn't required. - Required com.android.build.gradle.internal.dependency.BuildTypeAttr 'BuildTypeAttr{name=debug}' but no value provided. - Found com.android.build.gradle.internal.dependency. 'BuildTypeAttr{name=release}' but wasn't required. - Found com.android.build.gradle.internal.dependency.VariantAttr 'VariantAttr{name=prodRelease}' but wasn't required. - Required myflavor 'ProductFlavorAttr{name=prod}' but no value provided. - Found myflavor 'ProductFlavorAttr{name=prod}' but wasn't required. - Required org.gradle.api.attributes.Usage 'for compile' and found compatible value 'for compile'. 

Каков правильный способ включить my: util lib, не получив ошибку?

Solutions Collecting From Web of "Аромат ошибки градиента – Android Studio 3.0 Canary 1"

Похоже на ошибку в процессе сборки Gradle, я не совсем уверен, почему именно она не работает. Я застрял на этом некоторое время, но я смог исправить это, изменив

 compile project(':util') 

в

 compile project(path: ':util', configuration: 'default') 

Дайте мне знать, если это сработает для вас!

У меня была аналогичная проблема с Canary 2, но предлагаемое решение не сработало. По-видимому, есть способ использовать реализацию из локальной библиотеки или проекта:

 // 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') 

Ссылка из Studio Documentation .