Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio product flavors only recognized one out of two flavours

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.

image 1

image2

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?????

like image 788
Castell James Avatar asked Jul 13 '15 03:07

Castell James


People also ask

What are product Flavours in Android?

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.

What is Flavour dimension android?

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 { ...

What are the variants of Android?

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.


1 Answers

You also need to select your current flavour on the panel Build variants to the left of the IDE window.

like image 163
AndroidEx Avatar answered Nov 11 '22 12:11

AndroidEx