Android 所有产品风格都连接到一个构建变体
在我的项目中,我创建了产品风格:Android 所有产品风格都连接到一个构建变体,android,build,Android,Build,在我的项目中,我创建了产品风格:蓝色,绿色,红色。但当我查看构建变量时,它会显示blueRedGreenDebug,blueRedGreenRelease。如下图所示 产品风味 构建变量 如您所见,您必须定义维度 android { ... defaultConfig {...} buildTypes { debug{...} release{...} } // Specifies one flavor dimension
蓝色
,绿色
,红色
。但当我查看构建变量时,它会显示blueRedGreenDebug
,blueRedGreenRelease
。如下图所示
产品风味
构建变量
如您所见,您必须定义维度
android {
...
defaultConfig {...}
buildTypes {
debug{...}
release{...}
}
// Specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
demo {
// Assigns this product flavor to the "version" flavor dimension.
// This property is optional if you are using only one dimension.
dimension "version"
}
full {
dimension "version"
}
}
}
正如您所看到的,您必须定义维度
android {
...
defaultConfig {...}
buildTypes {
debug{...}
release{...}
}
// Specifies one flavor dimension.
flavorDimensions "version"
productFlavors {
demo {
// Assigns this product flavor to the "version" flavor dimension.
// This property is optional if you are using only one dimension.
dimension "version"
}
full {
dimension "version"
}
}
}
试试这个,它肯定会对你有所帮助。
flavorDimensions "paid", "free", "other"
productFlavors {
blue {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'blue'
dimension "paid"
applicationId "com.itroom.productFlavors.blue"
}
green {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
dimension "other"
applicationId "com.itroom.productFlavors.green"
}
red {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'red'
dimension "free"
applicationId "com.itroom.productFlavors.red"
}
}
替换为
flavorDimensions "default"
productFlavors {
blue {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'blue'
applicationId "com.itroom.productFlavors.blue"
}
green {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
applicationId "com.itroom.productFlavors.green"
}
red {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'red'
applicationId "com.itroom.productFlavors.red"
}
}
试试这个,它肯定会对你有所帮助。
flavorDimensions "paid", "free", "other"
productFlavors {
blue {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'blue'
dimension "paid"
applicationId "com.itroom.productFlavors.blue"
}
green {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
dimension "other"
applicationId "com.itroom.productFlavors.green"
}
red {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'red'
dimension "free"
applicationId "com.itroom.productFlavors.red"
}
}
替换为
flavorDimensions "default"
productFlavors {
blue {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'blue'
applicationId "com.itroom.productFlavors.blue"
}
green {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
applicationId "com.itroom.productFlavors.green"
}
red {
targetSdkVersion 27
versionCode 1
versionName "1.0"
versionNameSuffix 'red'
applicationId "com.itroom.productFlavors.red"
}
}
请给我看整个
build.gradle
文件,我会给你一个解决方案。请给我看整个build.gradle
文件,我会给你一个解决方案。