earizon
earizon

Reputation: 2238

Android Studio. Organizing project for Google Play: Same application, different assets

I developed a "template" application that I want to distribute on Google Play using different names and assets depending on the specific domain I'm targeting the app for (general, "domain1", "domain2", ...).

I have read in other posts that the first thing to do is to change the package name for each new application (in fact Google Play uses it as index, so it can NOT be repeated).

The easy solution I see is to create a new project and change the package name and assets, but this is quite "bloated". I'm wondering whether it's possible somehow to use a single AndroidStudio project to generate the "template application" and the "domain specific" ones.

Upvotes: 0

Views: 45

Answers (1)

MohK
MohK

Reputation: 1933

You can Define product flavors in the build file like general , domain1 ,domai2, .....

...
android {
    ...
    defaultConfig { ... }
    signingConfigs { ... }
    buildTypes { ... }
    productFlavors {
        general {
            applicationId "com.buildsystemexample.app.general"
            versionName "1.0-demo-general"
        }
        domain1 {
            applicationId "com.buildsystemexample.app.domain1"
            versionName "1.0-full-domain1"
        }
        ...
        ...
    }
}
...

As you see, all flavours will have different applicationId.

And moreover , you can have different resources or src or assets for your flavors as you want.

All you have to do is build the flavor you want from android studio.

Read more here. https://developer.android.com/tools/building/configuring-gradle.html

Upvotes: 1

Related Questions