10

After updating to Gradle plugin 3.0.0 beta 4 our build failed with the following message:

buildTypeMatching has been removed. Use buildTypes.<name>.fallbacks

Our libraries have release and debug buildTypes, but our app has two additional buildTypes: 'releaseWithLogs' and 'debugMinified'.

Snippet of our app Gradle file:

android {
    // ...
    buildTypeMatching 'releaseWithLogs', 'release'
    buildTypeMatching 'debugMinified', 'debug'

    buildTypes {
        debug {
            // ...
        }
        debugMinified {
            // ...
        }
        release {
            // ...
        }
        releaseWithLogs {
            // ...
        }
    }
}
Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50

1 Answers1

26

After some investigation, the following announcement has been found: Android Studio 3.0 Beta 4 is now available. There, it mentions:

You now provide fallbacks for missing build types and flavors using matchingFallbacks (which replaces buildTypeMatching and productFlavorMatching). You also provide the default selection and fallbacks for missing dimensions using missingDimensionStrategy (which replaces flavorSelection).

So, our previous app build.gradle gets converted to:

android {
    // ...
    //buildTypeMatching 'releaseWithLogs', 'release' // remove this
    //buildTypeMatching 'debugMinified', 'debug'     // remove this

    buildTypes {
        debug {
            // ...
        }
        debugMinified {
            // ...
            matchingFallbacks = ['debug']    // instead use this
        }
        release {
            // ...
        }
        releaseWithLogs {
            // ...
            matchingFallbacks = ['release']  // instead use this
        }
    }
}

Notice that, instead of saying that buildType releaseWithLogs will also match with release (buildTypeMatching 'releaseWithLogs', 'release'), we specify the match inside the buildType itself. Same for debugMinified matching debug. Also notice that there's no need to include this in release and debug buildTypes, as they already match.

Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50
  • 1
    This is not specified in the documentation, but does `matchingFallbacks = ['...'] ` need to be the last instruction of the `buildType` as it didn't work for me when I set it as the first one? – Eselfar Sep 20 '17 at 10:39
  • @Eselfar I don't think so. Could you open a new question with additional information so I can try to help and paste the link here as a comment? – Xavier Rubio Jansana Sep 20 '17 at 14:52
  • @IgorGanapolsky I don't see the relationship with just the information you provide. I guess you have searched in SO for it and you've got here. Could you provide more details? Maybe would be good to open a specific question, referencing this answer. – Xavier Rubio Jansana Apr 10 '18 at 15:59