1

In my current build scripts I have special /res/ and /assets folders that I copy over the working versions of the files at build time. In /assets/ is bundled data (sql and a text file) while in /res/values/ I have a connection.xml values file.

There are already duplicates of these files in the working directory, however at build time I want to use the ones from the /config/ folder of my project and copy them over the ones in the /res and /assets for the current build.

In my verbose logging I get a "com.android.ide.common.res2.DuplicateDataException" when it tries to copy the file.

Any idea's how to handle this? I can make the filename unique, but the key/value pairs inside it will not be? Would that solve the issue?

My Build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.0'
    }
}
apply plugin: 'android'

android {
    compileSdkVersion "Google Inc.:Google APIs:18"
    buildToolsVersion "17"

    signingConfigs {
        release {
            storeFile file("../../TioClient/keystore/android.keystore")
            storePassword "REDACTED"
            keyAlias "pge-android"
            keyPassword "lightmaker"
        }
    }

    buildTypes {
        dev {
            signingConfig signingConfigs.release
        }
        tps {
            signingConfig signingConfigs.release
        }
        production {
            signingConfig signingConfigs.release
        }
    }

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 15
    }

    dependencies {
       compile project(':TioClient'); 
    }

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

        }
        instrumentTest.setRoot('tests')
    }


}
HaMMeReD
  • 2,440
  • 22
  • 29

1 Answers1

2

You can define assets at the buildtype level or product flavor level by including appropriate folders in your src.

Build type resources override flavor resources which override main resources.

Saad Farooq
  • 13,172
  • 10
  • 68
  • 94