How to add specific flavor of the liberary


(Pramendra Rathi) #1

I am working on android application in which i have a dependency on one library and that library have two flavor, i want to add one specific flavor of that library. Till now i have tried this with which i am getting this error:

Error:Configuration with name 'prod' not found.

Gradle File of app:

...
dependencies {
compile project(path: ':appcommon',  configuration: 'prod')
...

Gradle file of lib:

defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName “1.0”

}
productFlavors{
    prod{

    }
    debug{

    }
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs += ['src']
        resources.srcDirs += ['src']
        aidl.srcDirs += ['src']
        renderscript.srcDirs += ['src']
        res.srcDirs += ['res']
        assets.srcDirs += ['assets']
    }

    debug{
        res.srcDirs += ['debug/res']
    }
    prod{
        res.srcDirs += ['prod/res']
    }

}
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])