How would i go about obfuscating just one flavour.
Unfortunately flavour 2 relies on a module (jar) that uses some duplication of classes, and i cannot obfuscate it due to the way it is set up. (3rd party) So wish to skip obfuscating the flavour.
I do not seem able to define minifyENabled false in the flavours section, or add the flavour to the build section.
Note, there are actually 6 flavours in total. The desire is to pick and choose flavours that should be obfuscated
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
flavour1{
applicationId "uk.co.company.flavour1"
}
flavour2{
applicationId "uk.co.company.flavour2"
}
}
Code shrinking with R8 is enabled by default when you set the minifyEnabled property to true .
Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs. Let's assign two product flavors free and paid in our application.
Obfuscating package names myapplication. MyMain is the main application class that is kept by the configuration. All other class names can be obfuscated. Note that not all levels of obfuscation of package names may be acceptable for all code.
As long as there is not present minifyEnabled
in ProductFlavor
DSL object, then you have to create another buildType, e.g. releaseMinified
along with standard release
.
buildTypes {
release {
minifyEnabled false
}
releaseMinified {
minifyEnabled true
}
}
productFlavors {
minifiableFlavor{}
nonMinifiableFlavor{}
}
And enable this build type only for the flavor that needs that:
android.variantFilter { variant ->
if (variant.buildType.name.equals('releaseMinified') && !variant.getFlavors().get(0).name.equals('nonMinifiableFlavor')) {
variant.setIgnore(true);
} else if (variant.buildType.name.equals('release') && variant.getFlavors().get(0).name.equals('nonMinifiableFlavor')){
variant.setIgnore(true);
}
}
Then you'll end up with:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With