Android Studio Gradle - installing a module build option

I am setting up a project that is dependent on one module, and I could successfully make an APK file. All I did was add

compile the project (': ModuleName')

However, I am wondering if I can have a dependency on a module with a build error. Thus, [Project: debug ] depends on [Module: debug ], and [Project: release ] depends on [Module: release ]

Thanks!

+5
source share
2 answers

Currently, the Gradle toolchain by default creates libraries in the version version , regardless of what you choose as the type of your application assembly, there are some tips for this problem, but they are mainly related to your assembly configuration, and not including dependency .

The closest example I can imagine is to do the following:

dependencies { flavor1Compile project(path: ':lib1', configuration: 'flavor1Release') flavor1Compile project(path: ':lib1', configuration: 'flavor2Release') } 

But this is achieved through the creation of accessories, and not to create options.

+3
source

Update on Marcus's answer:

I don’t know with which version of Gradle / Android Studio, but now it can be done:

Update: publishNonDefault now deprecated and is no longer needed. Just use the configuration below.

### build.gradle library:

 android { ... publishNonDefault true } 

Build.gradle application:

 dependencies { debugCompile project(path: ':baseApp', configuration: 'debug') releaseCompile project(path: ':baseApp', configuration: 'release') } 

Changing the build option of one of them in Android Studio will change the build option of the other.

+8
source

Source: https://habr.com/ru/post/1207689/


All Articles