Issue
We need to build different looking apps for different clients from the same source base. The app for each client has to be branded - i.e. must have different images, colors, etc. Most of the resources - e.g. layouts, strings - will be shared among all clients.
We are thinking of using sourceSet
in build.gradle
. For example:
android {
...
sourceSets {
Main {
// resources common to all clients
resSrcDirs = 'res'
// resources specific to client1
resSrcDirs += 'client1/res'
// resources specific to client2
//resSrcDirs += 'client2/res'
...
// The same approach taken for manifest that contains application theme
manifestSrcFile=client1/AndroidMainifest.xml
// manifestSrcFile=client2/AndroidManifiest.xml
...
}
}
}
Before each build we will uncomment/comment out selected lines in build.gradle
.
We think that this would work but wonder if there is a better way of doing it.
Solution
You can use flavorDimensions,
android {
flavorDimensions "version"
productFlavors {
commom
client1
client2
}
}
then create your resource folder src/client1 & src/client2. In the Build Variants window,you can switch which style to run or debug.Refer to the figure below. If you selected client1Debug or client1Release,the resources in client1/res will override the resources of the same names in the main/res.
Answered By - JiajiaGu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.