相关疑难解决方法(0)

如何在Android Gradle配置中获取当前的buildType

我想基于当前的buildType在Android Gradle项目中动态添加依赖项.我知道我可以在依赖项中指定buildType:

compile project(path: ':lib1', configuration: 'debug')
Run Code Online (Sandbox Code Playgroud)

但是,如何使用当前的buildType来指定要导入的库的哪个变体,以便调试版本或发布版本自动导入库的调试版本或发行版本?我想要的是这样的(其中currentBuildType是一个包含当前使用的buildType名称的变量):

compile project(path: ':lib1', configuration: currentBuildType)
Run Code Online (Sandbox Code Playgroud)

我要导入的库项目已设置publishNonDefault true,因此将发布所有buildType.

android android-gradle-plugin

29
推荐指数
4
解决办法
3万
查看次数

标签 统计

android ×1

android-gradle-plugin ×1