resConfigs每个构建类型 [英] resConfigs per build type

查看:346
本文介绍了resConfigs每个构建类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖每个构建类型的 resConfigs ?我读过这样的口味,但我不会使用它们。我只是想为我的调试版本创建另一组受支持的语言。



这是我试过的:

  buildTypes {
debug {
resConfigsde,en//允许在调试版本中使用德语
}
版本{
signedConfig signingConfigs.release
resConfigsen//只发布
}
}

任何简单的想法,我可以实现吗?
解决方案

由于某些原因,单个buildType配置doesn' t支持你指出的 resConfigs 命令,但是 defaultConfig 不会,然后你可以用这个技巧来操纵它构建类型,即使没有配置风格:

  android {
defaultConfig {
resConfigsen
}
applicationVariants.all {variant - >
if(variant.buildType.name.equals(debug)){
variant.mergedFlavor.resourceConfigurations.add(de)
}
}
}


How can I override the resConfigs per build types? I read that flavors would allow that, but I don't use them. I just want for my debug build another set of supported languges.

Here is what I tried:

buildTypes {
    debug {
        resConfigs "de", "en" // allow also german in debug builds
    }
    release {
        signingConfig signingConfigs.release
        resConfigs "en"       // english only releases
    }
}

Any simple idea how I can achieve that?

解决方案

For some reason the individual buildType configs doesn't support the resConfigs command as you point out, but defaultConfig does and then you can use this trick to manipulate it per build type even without flavors configured:

android {
    defaultConfig {
        resConfigs "en"
    }
    applicationVariants.all { variant ->
        if (variant.buildType.name.equals("debug")) {
            variant.mergedFlavor.resourceConfigurations.add("de")
        }
    }
}

这篇关于resConfigs每个构建类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆