10

Lets say I have a white label app that Im converting to be built in android studio from eclipse. This app has about 10 iterations which all use mostly the same code base with different resources that all use the same name convention how ever some of the iterations have extra activities or services that arent needed in all builds.

I want to scrap the entire lot of old hard to maintain code bases which are all essentially the same and just use one android studio project. I understand the base of this set up with all the source files and res files but I'm stuck on how to handle the different manifest files.

Can I use flavors or buildtypes to handle the switching of multiple manifest files?

James andresakis
  • 5,335
  • 9
  • 53
  • 88
  • Related post - [Android Studio two flavors with different manifest files](https://stackoverflow.com/q/28478110/465053) – RBT Aug 19 '18 at 09:06

1 Answers1

17

Lets say I have a white label app that Im converting to be built in android studio from eclipse.

I have a white label app that Im converting to be built in android studio from eclipse.

Oh, no, wait — you didn't mean that literally...

:-)

Can I use flavors or buildtypes to handle the switching of multiple manifest files?

Absolutely. You can have manifests in the flavor and/or build type sourcesets (e.g., src/debug/AndroidManifest.xml). Their contents will be merged in with the manifest in main, the manifests in any attached AARs/Android library projects, and the various settings in build.config to create The One True Manifest for any given build. There is a page that describes the merger process and how various attributes can help control it, though it's a trifle confusing.

Doug Watkins
  • 1,387
  • 12
  • 19
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ah ha I thought I could but that documentation was quite an eyeful once I started reading through it (yes it's quite confusing at first glance). So how should I structure my project if I have one java source base but multiple resource bases and manifest files? – James andresakis Dec 18 '14 at 19:52
  • 2
    @Jamesandresakis: "So how should I structure my project if I have one java source base but multiple resource bases and manifest files?" -- well, since it appears that you are looking to have the different resources/manifest for different production builds (i.e., shippable variants from the "white label" base), product flavors would be the primary vehicle. Most of your Java code goes in `src/main/`, along with a base set of resources and a manifest. Overrides to those resources and manifest would go in flavor-specific sourcesets (e.g., `src/whiteLabelShippableVariant1/`). – CommonsWare Dec 18 '14 at 20:00
  • in which directory will the paid version manfest will be created ,will that be under resource folder – Srishti Roy May 29 '20 at 07:21
  • @SrishtiRoy: No, it would go in `src/paid/AndroidManifest.xml`, just as the `main` source set's manifest goes in `src/main/AndroidManifest.xml`. – CommonsWare May 29 '20 at 11:56