Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle include dependencies of a dependency

Scenario

I have two Android libraries:

  • Library A
  • Library B

Library B depends on Library A and includes it from its build.gradle.

My Android app needs to use Library B and some base classes from Library A. The only success I've had in doing this is including both libraries in my Android app's build.gradle and setting transitive to false.

Question:

Is there a way for me to only add Library B and have access to its dependency from my Android app?


Android Studio

Android Studio 3.1 Canary
Build #AI-171.4415322, built on October 24, 2017
JRE: 1.8.0_152-release-1012-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

Gradle

3.1.0-alpha01
like image 736
zafrani Avatar asked Sep 12 '25 22:09

zafrani


1 Answers

From comments if you need to use library A inside your app and your library A included into B using implementation project(':LibA'), then it won't be a transitive to your main app.

You have to include it into B using api, api project(':LibA').

The api configuration should be used for dependencies that are exported to external modules (transitive dependency). Vice-Versa implementation configuration should be used for dependencies that are internal to the component (not transitive dependency).