Ferde
Ferde

Reputation: 75

How to handle AndroidManifest file for different environments

We have three environments for our app - DEV, QA and PROD.

Now we have created three AndroidManifest files for those three envs(like AndroidManifest_QA.xml), and we have to change the file name EVERY TIME when we want to release a new version, which is not unfailing.

So, I am wondering if there is an easier way to handle this situation?

Thanks in advance.

Upvotes: 1

Views: 731

Answers (1)

narancs
narancs

Reputation: 5294

I would go for Gradle Flavours:

    buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

or you can make it more separated, by using build variants. I think this is what you are really looking for in your case:

 productFlavors {
    pro {
        applicationId = "com.example.my.pkg.pro"
    }
    free {
        applicationId = "com.example.my.pkg.free"
    }
}

buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }
}

a very good tutorial: http://www.techotopia.com/index.php/An_Android_Studio_Gradle_Build_Variants_Example

article: http://developer.android.com/tools/building/configuring-gradle.html

Let's consider the following example from the techotopia.com

productFlavors {
    phone {
        applicationId
        "com.ebookfrenzy.buildexample.app.phone"
        versionName "1.0-phone"
    }
    tablet {
        applicationId
        "com.ebookfrenzy.buildexample.app.tablet"
        versionName "1.0-tablet"
    }
}

if you need to separate the falvours on code level, than please see Xavier Ducrohet stackoverflow link below:

Using Build Flavors - Structuring source folders and build.gradle correctly

Upvotes: 1

Related Questions