我的应用程序中有两个构建变体,一个是标准应用程序版本,第二个是自定义应用程序。
productFlavors {
customConfig {
minSdkVersion 14
applicationId 'es.com.custom'
targetSdkVersion 22
versionCode 3
versionName '3.0.0'
}
standard {
minSdkVersion 14
applicationId 'es.com.standard'
targetSdkVersion 22
versionCode 3
versionName '3.0.0'
}
对于自定义,我必须实现新功能,但只是为了自定义,所以这些新功能在标准版本上不可用。我不确定我必须做什么。
1.- 两类,一类是标准要求,一类是定制要求
2.- 在标准类中做类似的事情:
if (getPackageName()==customConfig )
// do the custom things
else
//do the standard things
最佳答案
Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.
if(BuildConfig.Flavor.equals("customConfig"))
{
}
else
{
}
关于android - 不同构建变体中的不同代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43777949/