I need to use different image resoures at build time


(jpescatello) #1

Hello. I’m using Eclipse for Android dev and at build-time I want to specify a particular directory for images and strings which will vary depending on the client I’m building for. I have two directories in the project that hold these resources - res and res2 and my build.gradle file appears below. The problem is, even though when I have

res.srcDirs = ['res2']

, the resources from the res directory always get bundled into the apk.

I think flavors might come into play here, but I’m having trouble finding a good example of how to use them. Can anyone get me on the right path?

Thanks!

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath ‘com.android.tools.build:gradle:0.4’

} } apply plugin: ‘android’

dependencies {

compile fileTree(dir: ‘libs’, include: ‘*.jar’)

compile project(’:workspace:actionbarsherlock’)

compile project(’:workspace:android-switch-backport’)

compile project(’:Development:Clientwork:android-pin-number’) }

android {

compileSdkVersion 17

buildToolsVersion “17.0.0”

sourceSets {

main {

manifest.srcFile ‘AndroidManifest.xml’

java.srcDirs = [‘src’]

resources.srcDirs = [‘src’]

aidl.srcDirs = [‘src’]

renderscript.srcDirs = [‘src’]

res.srcDirs = [‘res2’]

assets.srcDirs = [‘assets’]

}

instrumentTest.setRoot(‘tests’)

}

}