gpt4 book ai didi

安卓工作室 : How to remove/filter build variants for default debug and release buildTypes and keep only those using custom buildTypes?

转载 作者:IT老高 更新时间:2023-10-28 22:22:04 25 4
gpt4 key购买 nike

我创建了如下的自定义 buildType:

 buildTypes {
releasefree.initWith(buildTypes.release)
releasefree {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
releasepro.initWith(buildTypes.release)
releasepro {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".pro"
}
debugfree.initWith(buildTypes.debug)
debugfree {
shrinkResources true
applicationIdSuffix ".debug"
debuggable true
}
debugpro.initWith(buildTypes.debug)
debugpro {
shrinkResources true
applicationIdSuffix ".pro.debug"
debuggable true
}
}

我永远不会使用默认的调试和发布构建类型,并希望将它们从构建变体列表中删除。我有不止几种口味,而且变种的列表太大了。删除具有默认调试和发布类型的变体会有所帮助,因为我永远不会使用它们。

我尝试如下使用变体过滤器,但它不起作用

android.variantFilter { variant ->
if(variant.buildType.name.endsWith('Release') || variant.buildType.name.endsWith('Debug')) {
variant.setIgnore(true);
}
}

我过滤变体的方式是否有问题,或者无法使用默认调试和发布构建类型删除变体。

最佳答案

想通了。这对我来说是一个非常愚蠢的错误。上述变体过滤器确实有效。名字都是小写的,我比较的字符串中的大写是罪魁祸首。

更改为以下内容(使比较字符串小写)使其按预期工作:

android.variantFilter { variant ->
if(variant.buildType.name.endsWith('release') || variant.buildType.name.endsWith('debug')) {
variant.setIgnore(true);
}
}

或者这个

android.variantFilter { variant ->
if(variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
}
}

关于安卓工作室 : How to remove/filter build variants for default debug and release buildTypes and keep only those using custom buildTypes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34336864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com