Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle 3.0.0 - add library dependency for specific flavors

My app includes a library and a 3 flavor debug, release and custom.
I don't want my app to include the library in 'custom' flavor Prior to gradle 3.0 I used :

releaseCompile project(path: ':myLib', configuration: "release")  
debugCompile project(path: ':..:myLib', configuration: "debug")  
// 'custom' ignored  

according to google migrate to android plugin for 3.0 I need to use implementation keyword with matchingFallbacks for 'custom' flavor.

I don't want to use 'matchingFallbacks' because I don't want my app to include the lib in 'custom' flavor.

Any idea how can I compile the lib only in debug and release?

edit

maybe its possible to add 'if' statement i.e:

if(flavor != custom){ 
    implementation project 'myLib' 
}
like image 395
Jonny Avatar asked Jan 28 '26 09:01

Jonny


1 Answers

I think you can achieve it by using something like this:

dependencies {
   // use only mylib for debug and release
   releaseImplementation project(path: ':mylib')
   debugImplementation project(path: ':mylib')

   // this will be used by all the flavor
   implementation "com.android.support:appcompat-v7:27.0.2'
}
like image 97
ישו אוהב אותך Avatar answered Jan 31 '26 17:01

ישו אוהב אותך



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!