Issue
As we know there are two ways of having separate res directories for each productFlavor or buildType.
First Approach is by having separate directories under the src folder e.g. src\flavor1\res, src\flavor2\res etc.
Second Approach is specifying the res directory under sourceSets in the build.gradle like
sourceSets {
main {
res.srcDirs = ['res']
}
dev {
res.srcDirs = ['res-dev']
}
}
I know for sure that resource merging will happen in the first approach and any missing resource in the separate directory for flavor will be picked up from the main's sourceSet.
Question is about second approach above.
Will resource merging happen in the same way as it happens with the first approach using separate folders? Here i am explicitly going to assign a separate directory. Does it still fallback to main for resources not found in the specified directory?
I ask this because of the example in THIS LINK on http://tools.android.com/ where towards the end of the article it shows 'src/main/res' being explicitly added as follows:
android.sourceSets { main.res.srcDirs = ['src/main/res', 'src/main/res2'] }
Has anyone done this and knows if the resource merging will still happen if i just give the additional directory and not main as an additional one? will it fallback to the main directory for missing resources?
Solution
Ok, I tried out for myself with each of the above scenarios. Findings were as follows:
- There is no need to specify the
src\main\resdirectory. The fallback happens in both approach to the main res directory. - This worked absolutely well for both
resandassetsfolder. And I assume it will work exactly same for other folders too. I did not need those so havent tried. But, I cant think of any reason why they wont work whenresandassetsfolders do.
Hence, it works as expected.
Answered By - Viral Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.