0

In an Android gradle project, I see the use of a library called Koin. Normally, as in all Android projects, you include the library in build.gradle like this:

implementation "org.koin:koin-core:$koin_version"

However in this project, there is nothing in any of the gradle files that contain this. I even did a file search to see where it is defined. The only place where I have seen it defined is when you select:

File > Project Structure > Dependencies

But when I build the project, it builds without any problems. How does gradle reference this dependency since it's not in the build.gradle file? Even though it's defined under:

File > Project Structure > Dependencies

there is no clear indication how gradle knows about this.

Johann
  • 27,536
  • 39
  • 165
  • 279
  • Are you sure? The Project Structure > Dependencies feature reads and writes the build.gradle file in the modules of the project. – Gabriele Mariotti Sep 03 '19 at 12:16
  • Actually some additional libraries can use koin as an DI. Check all of your libraries and see which library what include. Just select Gradle->app->Tasks->Help->dependencies – Dmitriy Mitiai Sep 03 '19 at 12:22
  • Absolutely sure. I believe that it can reference the library after another module that it depends on is imported. – Johann Sep 03 '19 at 12:23
  • It is hard to know what you are asking because we don't know the extra dependency in your project neither your project structure, so it could be as pointed in the first question or something else try to take a look at this answer https://stackoverflow.com/questions/39008887/how-do-i-show-dependencies-tree-in-android-studio/39020703 – cutiko Sep 03 '19 at 12:38

1 Answers1

1

The dependencies can be located on your machine or in a remote repository, and any transitive dependencies they declare are automatically included as well.

dependencies {
// Dependency on a local library module
implementation project(":mylibrary")

// Dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Dependency on a remote binary
implementation 'com.example.android:app-magic:12.3'
}

for more details Android build dependencies and kotlin Gradle

sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • I believe that there is one that you are missing. The project contains a dependency on another module located in another project. That project contains the dependency I was looking for. So when you include the other module, you include all of its dependencies. So even though I couldn't find the dependency in the project, it gets it indirectly from the external module. – Johann Sep 03 '19 at 12:09
  • Instead of include other projects you want to include particular modules of other projects ? – sasikumar Sep 03 '19 at 12:22
  • Actually the project where I cannot find the Koin dependency is part of an Android library and a dependency is defined for that library. So indirectly, when it imports this library, it automatically has a reference to the Koin library. – Johann Sep 03 '19 at 12:24
  • yes thats happen because in app build.gragle we have plugin apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' – sasikumar Sep 03 '19 at 12:29
  • for more details refer this https://kotlinlang.org/docs/reference/using-gradle.html – sasikumar Sep 03 '19 at 12:33