Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use multiple manifest files for different gradle builds/flavors?

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?

like image 598
James andresakis Avatar asked Dec 18 '14 19:12

James andresakis


People also ask

How many manifest file can be in an application?

Your APK or Android App Bundle file can contain just one AndroidManifest. xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries.

How many application nodes are included in manifest?

A manifest can contain only one application node. It uses attributes to specify the metadata for your application (including its title, icon, and theme).

What is the use of manifest and Gradle files in Android application?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.

Why is manifest file required?

The manifest file is also where you can declare what types of hardware or software features your app requires, and thus, which types of devices your app is compatible with. Google Play Store does not allow your app to be installed on devices that don't provide the features or system version that your app requires.


1 Answers

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.

like image 121
CommonsWare Avatar answered Sep 18 '22 15:09

CommonsWare