0

I have 2 buildTypes and 5 productFlavors in my application.

buildTypes {
    debug {
        debuggable true
    }

    release {
        debuggable false
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

flavorDimensions "default"

productFlavors {
    dev {
        dimension "default"
        applicationIdSuffix ".dev"
        versionNameSuffix "_dev"
    }

    qa {
        dimension "default"
        applicationIdSuffix ".qa"
        versionNameSuffix "_qa"
    }

    demo1 {
        dimension "default"
        applicationIdSuffix ".demo"
        versionNameSuffix "_demo"
    }

    demo2 {
        dimension "default"
        applicationIdSuffix ".demo2"
        versionNameSuffix "_demo2"
    }

    prod {
        dimension "default"
    }
}

Then, I have lots of dependencies.

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:customtabs:25.3.1'

    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

    // this is the dependency I would like to modify
    compile 'com.appsee:appsee-android:2.3.4'
}

my goal is to configure something where one of the dependency is only added if the build variant is one of the following: demo2Debug, demo2Release, prodDebug and prodRelease

I've looked at many answers (like this or this) and they do one build variant at a time. Is there any way to say:

include this library is the build variant is this, this, this or this?

EDIT:

Another way to achieve this would be to exclude a dependency from one specific build variant.

Is there any way for me to say include this dependency for all build variants except for this?

ᴛʜᴇᴘᴀᴛᴇʟ
  • 4,466
  • 5
  • 39
  • 73
  • What you mean by this 'they do one build variant at a time' ? What you want to do exactly? – Krish Feb 01 '18 at 16:15
  • @Krish all examples I saw do the following: `demo2DebugCompile 'com.appsee:appsee-android:2.3.4'` then `demo2ReleaseCompile ...`, then `prodDebugCompile ...` and finally, `prodReleasCompile ...`. If I have do do this for 3 or 4 dependencies, it's just messy. Is there an easier way? – ᴛʜᴇᴘᴀᴛᴇʟ Feb 01 '18 at 16:49

0 Answers0