Reputation: 4627
I am using following flavors to improve debug builds for devices with Android 5 and above:
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 16
}
}
However not all of my devices runs under api 21+, thus I want to control multiDex and minifying. E.g.:
productFlavors {
dev {
minSdkVersion 21
multiDexEnabled false
minifyEnabled false
}
prod {
minSdkVersion 16
multiDexEnabled true
minifyEnabled true
}
}
But that's gives me:
Error:(44, 0) Could not find method minifyEnabled() for arguments [false] on ProductFlavor_Decorated
How can I combine those properties together?
Upvotes: 3
Views: 1670
Reputation: 321
As suggested by @maxost
just below i have provided android developers link
Refer here [https://developer.android.com/studio/build/multidex.html#dev-build]:
android {
defaultConfig {
...
multiDexEnabled true
}
productFlavors {
dev {
// Enable pre-dexing to produce an APK that can be tested on
// Android 5.0+ without the time-consuming DEX build processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the production version.
minSdkVersion 14
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Upvotes: 0
Reputation: 11058
minifyEnabled()
propery available only in BuildType DSL object. While multiDexEnabled
refers to ProductFlavor object. So if you want to combine these properties, you have to specify it in both of these objects. E.g.:
productFlavors {
dev {
minSdkVersion 21
multiDexEnabled false
}
prod {
minSdkVersion 16
multiDexEnabled true
}
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
}
}
For debug builds use devDebug
build variant, for release - prodRelease
.
Upvotes: 3