Sunday, February 25, 2018

Android studio | Dependency Management

Leave a Comment

Can anyone suggest, how can we add a dependency at build time in android gradle based on some condition like:

dependencies{        if(someCondition){            // add dependency        }     } 

Thanks in advance!!

1 Answers

Answers 1

I found a solution for this:

Step1: Declare a boolean variable in gradle at root level.

like: def someDependencyEnabled = true //This could be dynamically set. 

Step2: Using this boolean variable we can apply a check like:

if(someDependencyEnabled){     //Add some dependency } else {     //Add some other dependency } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment