I have two product flavors. Here is the app gradle:
flavorDimensions "default"
productFlavors{
publicVersion{
dimension "default"
}
privateVersion{
dimension "default"
}
}
I want a different Manifest file for each flavor. So I created a Manifest file with the path src/publicVersion/AndroidManifest.xml and a different one with the path src/privateVersion/AndroidManifest.xml, then I deleted the main Manifest file.
After I did that nothing worked. Android Studio is still demanding there be a Manifest file in the main directory. I tried all the answers on SO (like using "sourceSet" in the app gradle file) but they didn’t work. Perhaps recent Android Studio updates have changed the way to do it?
2
Answers
You can override the complete manifest in the individual flavours or define only the specialties in the flavours (IMHO better). If you add a permission in one flavour only, you only need to have a Manifest there with this single permission and it will be merged with the main permissions. If you want to modify an XML-Tag you can use
tools:node="merge"
andtools:node="replace"
.OPTION 1
Have
AndroidManifest.xml
for each flavourOPTION 2
Move the permissions into the product-flavor-dependent
AndroidManifest.xml
and leave the Activities and all other common information in one coreAndroidManifest.xml
app/src/main/AndroidManifest.xml
contains common information about Activities, … but no permissionsapp/src/flavor1/AndroidManifest.xml
contains only permissions for the flavor1 product flavorSimilarly for flavor2 in
app/src/flavor2/AndroidManifest.xml
For more info check this