2

I have developed a application which is distributed to different clients. The problem is that only the images and other resources that I use are different. What I'm currently doing is, that I replace the resources(images and text) specific to the client and build the apk.

Is there a way that I can store all Resources separately for each client and create a build script or something, so that I can choose the resources specific for the client I'm generating the apk during the build process?

kAnNaN
  • 3,669
  • 4
  • 28
  • 39
  • possible duplicate of [Multiple Android Application Package .apk files from single source code](http://stackoverflow.com/questions/7507784/multiple-android-application-package-apk-files-from-single-source-code) – 323go Mar 13 '14 at 14:01
  • 1
    Since those different APKs would require different package names, my suggestion is to place the bulk of your app into a library project and keep the client-specific apps/resource bundles as separate projects. This will be easier once gradle "flavors" are actually working. – 323go Mar 13 '14 at 14:04
  • 323go - I haven't create any library project. can u guide me with an example ? – kAnNaN Mar 13 '14 at 14:35
  • Google can help you: http://www.vogella.com/tutorials/AndroidLibraryProjects/article.html – 323go Mar 13 '14 at 15:02

1 Answers1

2

You can do it with such a script:

#!/bin/bash

ant clean

CUSTOMER_DIR="./default-customer"
if [[ -e ${CUSTOMER} ]]; then
  CUSTOMER_DIR="./${CUSTOMER}"
fi

rm -R ./res/drawables/
mkdir ./res/drawables/

cp ${CUSTOMER_DIR}/drawables/* ./res/drawables/

ant release

If you run it like this:

./build.sh

the drawables from default-customer/drawables/ directory will be copied to res/drawables.

If you run it like this:

CUSTOMER=client1 ./build.sh

the drawables from client1/drawables/ directory will be placed in res/drawables.

  • can the client1/drawables/ be stored any where on the system? – kAnNaN Mar 13 '14 at 14:48
  • 1
    In general - yes. You can modify the path of `CUSTOMER_DIR="./${CUSTOMER}"` and point it to the place you prefer. You can as well create a mapping of paths per client. I just showed you the concept of doing this. – Michał Kołodziejski Mar 13 '14 at 14:50