Issue
I have an android application and I would like to have different flavors. Specifically I would like to have 2 flavors and for each flavor use different strings (different strings.xml
file) and maybe have some icons different.
I have tried creating two folders in the project's root folder: flav1
and flav2
and used the following build.gradle
android {
compileSdkVersion "Google Inc.:Google APIs:15"
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
productFlavors {
flav1 {
packageName "com.ic.flav1"
}
flav2 {
packageName "com.ic.flav2"
}
}
android.sourceSets.flav2 {
res {
srcDir 'flav2'
}
resources {
srcDir 'flav2'
}
}
android.sourceSets.flav1 {
res {
srcDir 'flav1'
}
resources {
srcDir 'flav1'
}
}
}
The result of this is that none of the strings is recognized, getting multiple errors of the following type:
build FAILED :
error: Error: No resource found that matches the given name (at 'contentDescription' with value '@string/txt_addr').
Am I missing something? How should the build.gradle be?
Thanks
Solution
The solution was to add directory
values
under each corresponding res folder, and all the strings were recognized.
Answered By - Thomas Kaliakos
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.