I want to release my application in three stores. I have the rate section and update dialog in my application (which has a button to go to the store for update application). to manage these features I decide to make three flavors and three sources set to have different implementations of rate and update sections in different kotlin file. this is my Gradle file:
android {
flavorDimensions("appStores")
productFlavors{
create("p1Flavor"){
dimension="appStores"
sourceSets {
create("p1SourceSet"){
java.srcDirs("src/main/java","src/firstStoreDir")
}
}
}
create("p2Flavor"){
dimension="appStores"
sourceSets {
create("p2SourceSet"){
java.srcDirs("src/main/java","src/secondStoreDir")
}
}
}
create("p3Flavor"){
dimension="appStores"
sourceSets {
create("p3SourceSet"){
java.srcDirs("src/main/java","src/thirdStoreDir")
}
}
}
}
}
I want to add a directory that contains two files (updateStore.kt and rate.kt) to src for every flavor. I mean I have three directories with three different names which every directory contains updateStore.kt and rate.kt with different implementations.
when I build my project I get this error:
The SourceSet 'p1SourceSet' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
What should I do?
I realized that using source set is not appropriate for this situation and i decide to use buildConfigField.
and every where that i need to understand which flavor is selected, i use these codes :