New error after update to gradle-tool to 3.1.0-beta3 or 3.2.0-alpha03

耗尽温柔 提交于 2019-12-04 04:30:00

Encountered the same problem after updating the Gradle Plugin from 3.0.1 to 3.1.0. Seems like Gradle now only finds the source set for the variant that is selected in Android Studio.

A workaround that fixes it for now is to remove the sourceSets {} block and add this instead:

def customSourceSets = [
    myFirstBuildVariant: 'src/myFirstBuildVariant',
    mySecondBuildVariant: 'src/mySecondBuildVariant',
]

android.applicationVariants.all { 
    if (customSourceSets.containsKey(name)) {
        sourceSets.find { it.name == name }.setRoot(customSourceSets.get(name))
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!