Reputation: 83527
My understanding is that if you create a java
folder in any flavor it is detected automatically as a source set. This works perfectly for my first flavor. However, it fails for my second flavor (i.e. the java
folder doesn't turn blue). Any one know why this happens?
Here is my build.gradle
file:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "bbct.android.common"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
storeFile file("debug.keystore")
}
release {
storeFile file("codeguru.keystore")
keyAlias "codeguru"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
lite {
applicationId "bbct.android"
}
premium {
applicationId "bbct.android.premium"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
liteCompile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
}
Upvotes: 0
Views: 725
Reputation: 83527
According to this issue, the source folders in only the currently selected flavor will be recognized.
Upvotes: 1
Reputation: 13223
You need to add the flavor to gradle inside android{...}
:
productFlavors{
yourFirstFlavorFolderName{
}
yourSecondFlavorFolderName{
}
}
Then you will need to Sync Your Files With Gradle
and possibly Synchronize
your project. If this doesn't work you can check your .iml
file, look for the new added flavor, and make sure there is a line similar to this:
<sourceFolder url="file://$MODULE_DIR$/src/yourSecondFlavorName/java" isTestSource="false" />
Upvotes: 1