java - Gradle: How to create two applications for each flavor with different assets folders: -
currently i'm working on application has 5 flavors , part of build.gradle files matters:
buildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:0.14.0' } } apply plugin: 'com.android.application' repositories { mavencentral() } android { compilesdkversion 20 buildtoolsversion '20.0.0' signingconfigs { release { storefile file("") storepassword "password" keyalias "alias" keypassword "password" } } lintoptions { abortonerror false } defaultconfig { minsdkversion 14 targetsdkversion 20 applicationid 'application.package' signingconfig signingconfigs.release } buildtypes { release { signingconfig signingconfigs.release } } productflavors { flavor1{ applicationid 'com.flavor1.package' } flavor2{ applicationid 'com.flavor2.package' } flavor3{ applicationid 'com.flavor3.package' } flavor4{ applicationid 'com.flavor4.package' } flavor5{ applicationid 'com.flavor5.package' } } } dependencies { compile project(':sdk') }
i had make changes in file, it.
the question: have requirement provide each 1 of flavors different set of assets files in assets folder create different apk file have same package name. apk files uploaded google play same application different regions. package name have stay same. need create mechanism instead of 5 flavors created 10 flavor when every 2 of them have same package name different assets folder. how can done using gradle?
i have tried implementing using buildtypes so:
buildtypes { release { signingconfig signingconfigs.release sourcesets.main.assets.srcdirs = ['assets'] } releasealt { signingconfig signingconfigs.release sourcesets.main.assets.srcdirs = ['assetsalt'] } }
but reason releasealt takes files located in assets directory , not assetsalt directory. point me in right direction regarding one? in advance.
you can use buildtypes that.
buildtypes { release { // ... usual stuff here } releasealt { // .. usual stuff here signing config etc... } }
now file hierarchy :
you should have
project/ - app/ - src/ - main/ - assets/ - logo.png // generic assets go here - java/ - res/ - ... - flavor1/ - assets/ - logo.png // specific assets flavor1 variants - releasealt/ - asset/ - logo.png // specific assets releasealt variants. - flavor1releasealt/ - assets/ - logo.png // specific assets flavor1releasealt variant - sdk/
with file hierarchy, when build flavor1release
variant, have logo.png file flavor1/assets/
, when build flavor1releasealt
variant, png replaced on flavor1releasealt/assets/
folder.
explanation :
gradle using conventions on configurations (by default). when comes project structure. when flavor1releasealt variant being built, gradle (the android-plugin ;) ) looking folder called flavor1releasealt/ assets, resources, java etc... inside. theses specific app resources gradle find variant. gradle folder called flavor1/ less specifics app resources. lesser specific folder called releasealt/ , generic folder (main/).
the different folders have have strict names in order match variant lookup :
- flavorbuildtype/. (order important).
- flavor/
- buildtype/
- main/
hope helps.
Comments
Post a Comment