I am creating an application that should have two flavors, netball and football. When I set up my project as per https://developer.android.com/tools/building/configuring-gradle.html only one of the flavors are being recognized i.e netball and other flavor's package i.e football is not.
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.brawtasports.brawtasportsgps"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
netball {
applicationId "net.brawtasports.brawtasportsgps.netball"
versionName "1.0"
}
football {
applicationId "net.brawtasports.brawtasportsgps.football"
versionName "1.0"
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java']
res.srcDirs = ['src/main/res']
}
football {
java.srcDirs = ['src/football/java']
res.srcDirs = ['src/football/res']
}
netball {
java.srcDirs = ['src/netball/java']
res.srcDirs = ['src/netball/res']
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
I realize that is is only recognizing the first item in productFlavors i.e netball. if I place football first it will recognize football and not netball. What is wrong?????
Product flavours lets you create multiple variants of an android app while using a single codebase. To create product flavours you need to define rules in the build.
The flavor dimensions define the cartesian product that will be used to produce variants. Example: flavorDimensions("dimA", "dimB") productFlavors { row1 { ... dimension = "dimA" } row2 { ... dimension = "dimA" } row3 { ... dimension = "dimA" } col1 { ...
Once the new project is created, by default it consists of two build types/variants - debug, release. Debug is the build type that is used when we run the application from the IDE directly onto a device. A release is the build type that requires you to sign the APK.
You also need to select your current flavour on the panel Build variants
to the left of the IDE window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With