Dependencies
The dependencies are managed by Gradle Version Catalogs
Current Dependencies
| Dependency Name | Purpose | KMP | CMP |
|---|---|---|---|
| Compose | UI | ✅ | ❌ |
| Room | Database | ✅ | ❌ |
| Koin | Dependency Injection | ✅ | ✅ |
Adding New Dependency
Step 1
Add the required dependency detail in gradle/libs.versions.toml
[versions]
package_name = version
[libraries]
package-name-identifier = { module = path_to_maven_module, version.ref = package_name }Step 2
Bind the dependency on the appropriate build.gradle.kts file via:
implementation(libs.package.name.identifier)Periods in libs
If you notice, the package name we provided in the [libraries] section has dashes (-) in it. These dashes will be converted to periods (.) when used in build.gradle.kts
Where to place dependencies?
For all cases, the Step 1 is necessary. But binding the library to project differs with respect to use case
We’ve three build.gradle.kts files.
build.gradle.kts(The project level)composeApp/build.gradle.kts(For Compose Projects)shared/build.gradle.kts(For shared components)
Project Level
Normally, you wouldn’t be adding any dependencies here. This is where we configure everything on a project level, such as:
- Plugins you need to apply project-wide
- Common gradle tasks
Compose App Level
This is where we define dependencies which needs to go in the “App Level”. For example, if you are trying to add a new Android Library, or Desktop Library, this is where it should go.
sourceSets {
androidMain.dependencies {
// Android Specific Dependencies
}
commonMain.dependencies {
// Compose Multi Platform dependencies
}
}Source Sets
Remember, the “View” layer is technically Compose Multi Platform project. It’s just that we’re only developing Android. For reference, look at the Ideal Folder Structure
If you’re trying to add a dependency just for Android, link it in the androidMain.dependencies
If you’re trying to add a dependency just for Desktop, link it in the desktopMain.dependencies (Not Available as of now)
If the dependency is common, or in other words, Compose Multi Platform Compatible, put it in the commonMain.dependencies
Shared
This is where Kotlin Multiplatform dependencies should reside.
Source Sets
Currently, there are only two source sets available.
commonMaincommonTest
So normally, we’ll be puttimg KMP dependencies on the commonMain.