4

I have an application that has to be branded for two different customers. The application design, code, usage and flow are identical. The branding is purely changing android resources to use different colors and fonts, currently. It's also possible that they would use different drawables and layouts. Also there are some resources that are the same for both brands.

Currently, we just have two different projects with duplicate code files but different sets of resource files.

Is it possible to have one project with all the resources (common resources, brand-1 resources and brand-2 resources) and have a compile time flag to decide which set of resources to use?

Edit: I am looking for something similar to having different sets of layouts and resources based on screen size and densities.

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • 2
    Solution lies in Gradle. Something like this might help you http://stackoverflow.com/questions/17103601/use-different-resources-for-different-application-flavors-using-gradle – Sharjeel Aug 27 '15 at 12:44
  • 1
    That's what `Android Studio` provide. – M D Aug 27 '15 at 12:47
  • well, that was quick and easy and exactly what I was looking for. Thanks fellas! – Bala R Aug 27 '15 at 12:49

3 Answers3

4

Use Android studio. In android studio you will have flavor folder inside project. one can put resources according to the flavor. example:

Project-
      flavor-
             demo-
             |   src-
             |      res-
             |         drawable-
             |                ic_launcher.png
             brand1-
             |    src-
             |      res-
             |         drawable-
             |                ic_launcher.png
             brand2-
                 src-
                   res-
                      drawable-
                             ic_launcher.png

and specify this in your gradle file like this.

 android{
 ....
 productFlavors {
        demo {
            applicationId "com.example.app.demo"
            versionName "1.0.3"
        }
        brand1 {
            applicationId "com.example.app.brand1"
            versionName "1.0"
        }
         brand2 {
                applicationId "com.example.app.brand2"
                versionName "1.4"
            }
    }
 ...}

You have option to choose the Build Variant at the left side of android studio.It will pick up the resource according to the flavor you choose.

Please note: Android Studio is slow. You should have minimum of 8gb ram.

Read this documentaion

2

You can achieve this using build variants. You would simply create two flavors for each client, alter whatever resources need changing in the appropriate sourceSets, then choose your flavor & build.

fractalwrench
  • 4,028
  • 7
  • 33
  • 49
0

Take a look at this. i was reading through it, it might be of help to you too regarding how to provide alternate resources.

Thanks,

Kaveesh Kanwal
  • 1,753
  • 17
  • 16