因为升级 build:gradle 3.1到 build:gradle 3.4
com.android.tools.build:gradle:3.1.0
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
API variable.getMergeAssets ()已过时,已替换为variant.getMergeAssetsProvider()
解决方法:
app目录下build.grade中,更改variant.mergeAssets.doLast 为 variant.mergeAssetsProvider.get().doLast :
android.applicationVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
variant.mergeAssets.doLast {
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
}
修改后为
android.applicationVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
variant.mergeAssetsProvider.get().doLast {
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
}