Build Variant Android studio

0

Why does my build variants (first image) not have the options I want for the build? In this case I intended the "mockdebug" as shown in the second image.

WhatdoIneedtodotogetalltheseoptionsinbuildvariants?

build.gradle

applyplugin:'com.android.application'android{compileSdkVersion25buildToolsVersion"25.0.2"
        defaultConfig {
            applicationId "com.example.projeto"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        sourceSets {
            main {
                java.srcDirs = ['src/main/java']
            }
            test {
                java.srcDirs = ['src/test/java', 'src/main/java']
                resources.srcDirs = ['src/test/res', 'src/main/res']
            }
            androidTest {
                java.srcDirs = ['src/androidTest/java', 'src/main/java']
                resources.srcDirs = ['src/androidTest/res', 'src/main/res']
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        // Optional -- Mockito framework
        compile 'com.android.support:appcompat-v7:25.3.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.1'
        compile 'com.prolificinteractive:material-calendarview:1.4.3'
        compile 'com.android.support:support-v4:25.3.0'
        compile 'com.android.support:recyclerview-v7:25.3.0'
        compile 'com.android.support:design:25.3.0'
        compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
        testCompile 'junit:junit:4.12'
        testCompile 'org.mockito:mockito-core:1.10.19'
        testCompile 'org.robolectric:robolectric:3.0'
        androidTestCompile 'junit:junit:4.12'
        androidTestCompile 'com.android.support:support-annotations:25.3.0'

        //Android testing support librarys runner and rules
        androidTestCompile('com.android.support.test:runner:0.5') {
            // Necessary if your app targets Marshmallow (since the test runner
            // hasn't moved to Marshmallow yet)
            exclude group: 'com.android.support', module: 'support-annotations'
        }
        androidTestCompile("com.android.support.test:rules:0.5") {
            exclude group: 'com.android.support', module: 'support-annotations'
        }

        //Expresso UI Testing dependencies
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
            exclude group: 'com.android.support', module: 'support-annotations'
        }
        androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'

        // add this for intent mocking support
        androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'

        // add this for webview testing support
        androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
    }
    
asked by anonymous 21.08.2017 / 16:18

1 answer

2

To add flavors as in the image, you must add a block of productFlavors to your build.gradle . Inside it you can create several flavors and customize them.

...
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
    prod {
        // Configurações de prod
    }
    mock {
        // Configurações de mock
    }
}
...
    
21.08.2017 / 18:02