Gradle插件3.0.0 beta 4:"buildTypeMatching已被删除.使用buildTypes.< name> .fallbacks" [英] Gradle plugin 3.0.0 beta 4: "buildTypeMatching has been removed. Use buildTypes.<name>.fallbacks"
问题描述
更新到Gradle插件3.0.0 beta 4后,我们的构建失败,并显示以下消息:
After updating to Gradle plugin 3.0.0 beta 4 our build failed with the following message:
buildTypeMatching已被删除.使用buildTypes.< name> .fallbacks
buildTypeMatching has been removed. Use buildTypes.<name>.fallbacks
我们的库有release
和debug
buildType
s,但是我们的应用程序还有两个另外的buildType
s:'releaseWithLogs'和'debugMinified'.
Our libraries have release
and debug
buildType
s, but our app has two additional buildType
s: 'releaseWithLogs' and 'debugMinified'.
我们的应用 Gradle文件的摘要:
Snippet of our app Gradle file:
android {
// ...
buildTypeMatching 'releaseWithLogs', 'release'
buildTypeMatching 'debugMinified', 'debug'
buildTypes {
debug {
// ...
}
debugMinified {
// ...
}
release {
// ...
}
releaseWithLogs {
// ...
}
}
}
推荐答案
After some investigation, the following announcement has been found: Android Studio 3.0 Beta 4 is now available. There, it mentions:
现在,您可以使用
matchingFallbacks
(代替buildTypeMatching
和productFlavorMatching
)为缺少的构建类型和风味提供后备.您还可以使用missingDimensionStrategy
(代替flavorSelection
)为缺少的尺寸提供默认选择和后备广告.
You now provide fallbacks for missing build types and flavors using
matchingFallbacks
(which replacesbuildTypeMatching
andproductFlavorMatching
). You also provide the default selection and fallbacks for missing dimensions usingmissingDimensionStrategy
(which replacesflavorSelection
).
因此,我们之前的 app build.gradle被转换为:
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
}
}
}
请注意,我们在buildType
本身内部指定了匹配项,而不是说buildType
releaseWithLogs
也将与release
(buildTypeMatching 'releaseWithLogs', 'release'
)匹配.与匹配debug
的debugMinified
相同.另外请注意,由于它们已经匹配,因此不必将其包含在release
和debug
buildType
中.
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
buildType
s, as they already match.
这篇关于Gradle插件3.0.0 beta 4:"buildTypeMatching已被删除.使用buildTypes.< name> .fallbacks"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!