Android Studio 3 + Gradle 4.0 + shrinkResources + libraryProject = Unable to find a matching configuration in project

Possible workaround is create in all modules missing buildTypes, but it’s crazy messing code when Google planed create a sollution for it. More info in: as me (but deleted by moderator) and you mention.

But there is second (same but much cleaner) solution:
add this to your top project build.gradle

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                buildTypes {
                    YOUR_MISSING_BUILD_TYPES {

EDIT: 2017-07-12

It’s finally fixed in classpath ''.
You can use new DSL:

android {
  buildTypeMatching 'staging', 'debug'
  productFlavorMatching 'color', 'blue', 'cyan'

Don’t forgot to remove above workaround before build project!

EDIT: 2017-07-18

There is official documentation:

To resolve this error, you need to specify which build type from
“mylibrary” the Android plugin should match to the app’s “staging”
build type. You can do this with the buildTypeMatching property in the
app’s build.gradle file, as shown below:

// Add the following to the consumer's build.gradle file.
android {
    // Tells the Android plugin to use a library's 'debug' build type
    // when a 'staging' build type is not available. You can include
    // additional build types, and the plugin matches 'staging' to the
    // first build type it finds from the one's you specify. That is,
    // if 'mylibrary' doesn't include a 'debug' build type either, the
    // plugin matches 'staging' with the producer's 'release' build type.
    buildTypeMatching 'staging', 'debug', 'release'

EDIT: 2017-09-06

buildTypeMatching has been removed from AS beta 4.
now use matchingFallbacks.

IF your app includes a build type that a library dependency does not.

For example, your app includes a “staging” build type, but a dependency includes only a “debug” and “release” build type.

You will get error like

Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve project :library. Open File Show Details

You can resolve this error by adding

buildTypes {
        staging {
            proguardFile getDefaultDexGuardFile('')
            proguardFile ''
            matchingFallbacks = ['debug', 'release'] //add this line

Resolve build errors related to dependency matching official docs

Leave a Comment