3

App level build gradle dependencies

devCompile project(path: ':mymodule', configuration: 'devRelease')
proCompile project(path: ':mymodule', configuration: 'proRelease')
qaCompile project(path: ':mymodule', configuration: 'qaRelease')
offlineCompile project(path: ':mymodule', configuration: 'offlineRelease')

mentioned

publishNonDefault true
flavorDimensions "default"

I have tried This accepted answer but didn't work.

Update: Look at the library gradle flavor that I want to compile. I have the same flavor mentioned in my app's Module.

        dev {
            manifestPlaceholders = [facebookId: "SOME_FACEBOOK_ID_1"]
        }
        pro {
            manifestPlaceholders = [facebookId: "SOME_FACEBOOK_ID_2"]
        }
        qa {
            manifestPlaceholders = [facebookId: "SOME_FACEBOOK_ID_3"]
        }
        offline {
            manifestPlaceholders = [facebookId: "SOME_FACEBOOK_ID_4"]
        }
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
Aks4125
  • 4,522
  • 4
  • 32
  • 48

2 Answers2

2

You just need to reduce the details you provide:

compile project(path: ':mymodule')

The details what in which configuration is decided by gradle now by themselves. So it became way easier. Instead of 4 lines you just need the above now.

Also remove the publishNonDefault true from your modules gradle. It is not needed anymore.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
  • i'll give a try and respond you back for the same. – Aks4125 Nov 13 '17 at 11:32
  • @WarrentFaith I have tried this and it is getting compiled. But the issue is, it is not compiling specific flavor. But any of them will get compile. I want to compile App's dev flavor with Library's dev flavor. – Shreyash Mahajan Nov 13 '17 at 11:37
  • 1
    If both have the same flavor and dimension defined, gradle picks the same. So "devProductionRelease" for your app will use the "devProductionRelease" for your library too. How do you found out that it does not work as you think it does? – WarrenFaith Nov 13 '17 at 11:39
  • See, I have facebook ID added for each flavor in Library's gradle file. So, when I run devDebug it works fine. Now, when I run stagingDebug it shows a conflict of the Facebook provider. it shows like the specific flavor of the library is not getting compile with App module. – Shreyash Mahajan Nov 13 '17 at 11:43
  • I recommend to no do it this way. The facebook api key is part of the app configuration because for every app it would differ. That is why you should move this into the flavor definition of your apps gradle file and not the one of your library. – WarrenFaith Nov 13 '17 at 11:53
  • @WarrenFaith I would really like to know, Here we have facebook id which can be defined by App's module and resolved this issue. But how we can do, if we really need to compile specific flavor of App's module with the specific flavor of Library's module. – Shreyash Mahajan Nov 13 '17 at 13:20
1

Dependency management between modules has changed since Android Gradle Plugin 3.0.0. It automatically tries to matches flavours between your app and the libraries/modules it depends on.

See the documentation for more explanation!

galex
  • 3,279
  • 2
  • 34
  • 46
  • Can you please share some example. I want to compile specific flavor of library while I am compiling specific flavor of my app. Like compiling dev flavor of App module and Library module. – Shreyash Mahajan Nov 13 '17 at 10:56