I have solved the problem
Part 1 : k3v1n4ud3's link did help a lot to coalesce the information. Thank you for that.
Here is my entire build.gradle located under the project folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
signingConfigs {
debug {
storeFile file("debug.keystore")
}
release {
storeFile file("D:\\AndroidStudioProjects\\KeyStore\\Keystore_password1.jks")
storePassword "password"
keyAlias "MyAppName"
keyPassword "password"
}
}
productFlavors {
free {
packageName "com.mypackage.myappname"
}
paid {
packageName "com.mypackage.myappname"
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
signingConfig signingConfigs.release
debuggable false
zipAlign true
}
/*
alpha {
packageNameSuffix ".alpha"
}
beta {
packageNameSuffix ".beta"
}*/
}
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
android.applicationVariants.all { variant ->
if (variant.buildType.name == "release") {
switch (variant.name) {
case "FreeRelease":
variant.mergeResources.doFirst {
android.sourceSets.debug.setRoot("src/free")
}
break;
case "PaidDebug":
variant.mergeResources.doFirst {
android.sourceSets.debug.setRoot("src/paid")
}
break;
}
}
else if (variant.buildType.name == "debug") {
switch (variant.name) {
case "FreeDebug":
variant.mergeResources.doFirst {
android.sourceSets.debug.setRoot("src/debug/free")
}
break;
case "PaidDebug":
variant.mergeResources.doFirst {
android.sourceSets.debug.setRoot("src/debug/paid")
}
break;
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
Part 2: I used the keystore created when I initially used the Build->Generate Signed APK... wizard. Pay attention to the keyalias used. After half a day of banging my head against the wall i had forgotten what I'd typed :-)
Part 3: This thread helped me set up the source folders and understand the flavors. Folder naming convention for gradle build variants
Part 4: With just one AndroidManifest.xml I couldn't use the suffixes on the package names. With suffixes it was rejected when uploading to the device. That becomes a problem when pretty much every example of build.gradle includes suffixes.
Part 5: Use View->Tool Windows->BuildVariants to bring up the build variants. The second column is actually a drop down. Select what you want to build here otherwise it's just going to keep building the debug version. (Why on earth it's not under the build menu or the run/debug configurations is a mystery???)
Part 6: The future... I have to try and work out the flavors and how to set them up as I would eventually like to deploy a free and a paid version off the same code base. I will start signing the debug versions with my own key as well.