I am converting one of my apps to Gradle and would like to use the new build flavor features to have a paid and a free ad based flavor.
I want only the ad based version to depend on the admob SDK.
My build file looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
productFlavors {
Pro {
packageName "de.janusz.journeyman.zinsrechner.pro"
}
Free {
dependencies {
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile fileTree(dir: 'libs', include: '*.jar')
}
Is there a way to configure the dependency in the free product flavor to have its own libs folder that is merged with the main libs folder that contains general libraries for both flavors?
If this is possible how would I define this folder?
Edit: I recommend using one of the other techniques!
An alternative to the accepted answer is this:
Fast forward to mid-2018. You will need to add
flavorDimensions
.Also, take note:
You need to manually add configuration for each flavor. Example
To define a flavor specific dependency you can use
proCompile
instead ofcompile
in your dependency section. When you run gradle properties you get an overview of automatic created configurations.The correct build file looks like this: