Android flavors, Gradle sourceSets merging -
i try make application multiple partners , each partner test , prod version. each flavors create specific folder res/values in documentation said.
my gradle file :
apply plugin: 'com.android.application' android { packagingoptions { exclude 'meta-inf/license' exclude 'meta-inf/notice' } compilesdkversion 14 buildtoolsversion "21.1.2" defaultconfig { versioncode 1 versionname 1 minsdkversion 14 targetsdkversion 19 } productflavors { prodpartner1 { applicationid "com.partner1" } testpartner1 { applicationid "com.partner1.test" } prodpartner2{ applicationid "com.partner2" } testpartner2{ applicationid "com.partner2.test" } } sourcesets { testpartner2 { res.srcdirs = ["testpartner2/res", "prodpartner2/res"] } } } dependencies { compile project(':viewpagerindicatorlibrary') compile 'com.android.support:support-v4:19.0.0' compile 'com.google.android.gms:play-services:+' compile files('libs/achartengine-1.1.0.jar') compile files('libs/android-async-http-1.4.4.jar') compile files('libs/jackson-annotations-2.2.3.jar') compile files('libs/jackson-core-2.2.3.jar') compile files('libs/jackson-databind-2.2.3.jar') compile files('libs/urlimageviewhelper-1.0.4.jar') }
i want test version take res folder of prod version (like not duplicate resources both version) , merge test version. problem :
error:error: duplicate resources:
c:\...prodpartner2\res\values\strings.xml:string/app_name,
c:\...testpartner2\res\values\strings.xml:string/app_name
any idea ? it's not possible merge res folder same flavors ?
edit : use gradle v 1.1.0 , android studio v 1.1.0 too
use productflavors
each partner app , define build type test
test builds.
productflavors { partner1 { applicationid "com.partner1" } partnern { applicationid "com.partnern" } } buildtypes { debug { // use defaults } release { // 'prod' version, use defaults } test { // config want! applicationidsuffix ".test" versionnamesuffix " test" debuggable true minifyenabled false signingconfig signingconfigs.debug } }
you can use mix , match source folders android plug-in gradle shows:
to build each version of app, build system combines source code , resources from:
src/main/
- main source directory (the default configuration common variants)src/<buildtype>/
- source directorysrc/<productflavor>/
- source directory
edit: user guide source of help: http://tools.android.com/tech-docs/new-build-system/user-guide
edit 2: according link above:
additional sourcesets created each variants:
android.sourcesets.flavor1debug
locationsrc/flavor1debug/
android.sourcesets.flavor1release
locationsrc/flavor1release/
android.sourcesets.flavor2debug
locationsrc/flavor2debug/
android.sourcesets.flavor2release
locationsrc/flavor2release/
then, can use /src/partner1test/
define resources specifics partner1
flavor , test
build, partner1test
build variant.
Comments
Post a Comment