Code-Apprentice
Code-Apprentice

Reputation: 83527

Default sourceSets in Android Studio 0.6.0

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

Answers (2)

Code-Apprentice
Code-Apprentice

Reputation: 83527

http://code.google.com/p/android/issues/detail?id=69257&q=android%20studio%20flavor&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

According to this issue, the source folders in only the currently selected flavor will be recognized.

Upvotes: 1

Emmanuel
Emmanuel

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

Related Questions