Question

I have a gradle.build which works fine for main goal. I would like to add flavor for skinning version. I have add them into gradle build but I don't understand where I should put another version of files, in which folder and what name it should be? Lets consider an example: main package is com.example.app with project structure common to android app (I do it in sourceSets). As I understand I should create folder (not a set of sub folders) com.example.app.flavor and put in \res which already contains files for main project but it doesn;t work when I build assembleFlavorDebug -- apk is built but it contains the main app but doesnt have a changes in flavor

apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    compile 'commons-io:commons-io:2.4'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.google.android.gms:play-services:3.2.+@aar'
    compile project(':ViewPagerIndicator')
    compile project(':AndroidHorizontalListView')
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.0"

    productFlavors {
        app {
            packageName="com.example.app"
        }
        flavor {
            packageName="com.example.app.flavor"
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')


        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
    }
Was it helpful?

Solution

You should create a subfolder named flavor under src. The structure of the flavor subfolder is identical to the structure of main:

  • java - contains all .java source files
  • res - contains Android resource subfolders (drawable, layout, values, etc.)
  • AndroidManifest.xml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top