找不到匹配的配置

找不到匹配的配置

本文介绍了Gradle 4.0 找不到匹配的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新的 Android Studio 3.0 canary 2 中打开我现有的项目.我根据 说明,更改了依赖项配置的名称,但我继续遇到下一个错误:

I am trying to open my existing project in new Android Studio 3.0 canary 2. I updated Gradle according to instructions, changed names for dependency configurations but I continue to get next error:

Unable to resolve dependency for ':app@productionRelease/compileClasspath':
Could not resolve project : abChat.

在另一个窗口中:

Error:Could not resolve all dependencies for configuration ':bankOK:betaNewApiInnerTestRuntimeClasspath'.
> Unable to find a matching configuration in project :abChat:
    - Configuration 'debugApiElements':
        - Required apiLvl 'ProductFlavorAttr{name=newApi}' but no value provided.
        - 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=innerTest}' 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 releaseType 'ProductFlavorAttr{name=beta}' but no value provided.
    - Configuration 'debugRuntimeElements':
        - Required apiLvl 'ProductFlavorAttr{name=newApi}' but no value provided.
        - 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=innerTest}' 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 releaseType 'ProductFlavorAttr{name=beta}' but no value provided.
    - Configuration 'releaseApiElements':
        - Required apiLvl 'ProductFlavorAttr{name=newApi}' but no value provided.
        - 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=innerTest}' 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 releaseType 'ProductFlavorAttr{name=beta}' but no value provided.
    - Configuration 'releaseRuntimeElements':
        - Required apiLvl 'ProductFlavorAttr{name=newApi}' but no value provided.
        - 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=innerTest}' 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 releaseType 'ProductFlavorAttr{name=beta}' but no value provided.

以下是我们的构建类型和风格:

Here are our build types and flavors:

buildTypes {

        release {
           //...
        }

        debug {
           //...
        }

        innerTest {
            //...
        }
    }



flavorDimensions "releaseType", "apiLvl"
    productFlavors {
        prod {
            dimension "releaseType"
            //...
        }
        beta {
            dimension "releaseType"
            //...
        }
        oldApi {
            dimension "apiLvl"
           //...
        }
        newApi {
            dimension "apiLvl"
            //...
        }
    }

此外,我们有一个名为abChat"的库模块,没有任何风格.我可以尝试做些什么来解决问题?

Also, we have a library module named "abChat" without any flavors.What can I try to do to solve the problem?

推荐答案

此问题已修复,并且在 Stable 3.0 版本中一切正常.如果您仍然遇到此问题,那是因为没有回退机制.

This issue is fixed and everything works fine in the Stable 3.0 version. If you still face this issue, that's because there is no fallback mechanism.

如果您的应用程序包含库没有的构建类型,那么您将收到此错误.要解决此问题,您需要为您的构建类型提供 matchingFallbacks.请参阅本文档中的解决与依赖项匹配相关的构建错误部分

If your app includes a build type that the library doesn't then you will get this error. To fix this, you need to provide matchingFallbacks to your build type. Refer the Resolve build errors related to Dependency matching section in this documentation

如果是构建类型,请执行以下操作,如果是产品风格,请参阅迁移文档.

In case of build types do the below, and if it's product flavors refer the documentation for migration.

buildTypes {
    release {
       //...
    }
    debug {
       //...
    }
    innerTest {
        //...
        matchingFallbacks = ['debug', 'release']
    }
}

并简单地添加您的依赖项,如下所示:

and simply add your dependencies like below:

dependencies {
    implementation project(':abChat')
}

这篇关于Gradle 4.0 找不到匹配的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 20:27