You're right Croc, I made a mistake in problem's description - it should be "freeFroyoCompile". However, I wrote it correctly in my gradle script.
Thank you Xavier, it almost work for me. Your example was not compiling, but I did my best to use your idea.
The code is below. Now I can compile for Froyo, but not for Gingerbread because resources from dependency are not accessible:
".../build/manifests/freegingerbread/debug/AndroidManifest.xml:40: error: Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version')."
When I run froyo version compiled with this script, admob jar seems not to be attached:
"E/dalvikvm﹕ Could not find class 'com.google.ads.AdView', referenced from method pl.aambitny.spellscontainer.view.common.AdUtils.reloadAd"
task fixDependencies << {
def freeFlavor = android.productFlavors.free;
def froyoFlavor = android.productFlavors.froyo;
def gingerbreadFlavor = android.productFlavors.gingerbread;
android.applicationVariants.all { variant ->
def flavors = variant.productFlavors;
if (flavors.contains(freeFlavor) && flavors.contains(froyoFlavor)) {
variant.javaCompile.classpath += configurations.freeFroyoCompile;
} else if (flavors.contains(freeFlavor) && flavors.contains(gingerbreadFlavor)) {
variant.javaCompile.classpath += configurations.freeGingerbreadCompile
}
}
}
tasks.whenTaskAdded { theTask ->
if (theTask.name.startsWith("compile")) {
theTask.dependsOn "fixDependencies"