0

I have followed Google's official doc for creating multiple APKs for different API levels. (I know it is not recommended to have different APKs, however in my specific case I must use it).

The only difference between the two APKs in my case would only the AndroidManifest.xml files content. While reading through the official doc which recommends creating a shared library between two different apps modules, I wondered whether it is going to be possible to achieve the same through different flavors in Gradle's build setting, specifying a different AndroidManifest.xml file for each flavor and thus generating two APKs with different manifests (the idea came from this post).

Since creating two flavors is much simpler (time and maintenance wise), and my only need is two different manifests files, isn't this a better option than the suggest common library module shared between two different app modules?

Community
  • 1
  • 1
Ooze
  • 1
  • https://developer.android.com/studio/build/build-variants.html – IntelliJ Amiya Aug 16 '16 at 05:22
  • Yes you can create different manifest file for each product flavour.You need to create your product flavour name folder in src folder and in that folder just put another manifest file with the changes you want. – Jay Shah Aug 16 '16 at 05:42

1 Answers1

1

You should check about Product flavors

A product flavor defines a customized version of the application build by the project. A single project can have different flavors which change the generated application.

Structure

 android {  
    productFlavors {
        dev {
            applicationId "root.com.android.dev"
        }

        product {
            applicationId "root.com.android"
        }
    }
}

You can read also

  1. Product flavors in Android Studio for hermetic testing
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198