I am developing an Android library, i use some dependencies in the project module which is published to a local maven repo, this is how i declare my dependencies in my gradle.build.kts
:
dependencies {
// Retrofit
implementation(libs.retrofit)
implementation(libs.retrofit.gson)
implementation(libs.okhttp)
implementation(libs.okhttp.logging)
// room
implementation(libs.room.runtime)
implementation(libs.room.ktx)
ksp(libs.room.compiler)
testImplementation(libs.room.testing)
// Work Manager
implementation(libs.work.runtime.ktx)
// Play services
implementation(libs.play.services.location)
// DI
implementation(libs.koin.android)
}
my publishing section i straight forward:
publishing {
publications {
create<MavenPublication>("release") {
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
groupId = "com.mylibrary.android"
artifactId = "core"
version = project.extra["baseVersionName"] as String
}
}
repositories {
maven {
url = uri("${project.buildDir}/repo")
}
}
}
I run ./gradlew assembleRelease
, than ./gradlew publish
and get an AAR file in a local location.
However, when i try to use this SDK in a sample app, using the line
implementation("com.mylibrary.android:core:0.3.1")
I get errors for java.lang.NoClassDefFoundError: Failed resolution of:
on my dependencies, as my sample app dont, nor do i want it to, declare any dependencies in its gradle file.
I have seen solutions for using api
instead of implementation
however this did not change the error.
I have seen talk of fat-aar but i am not sure that is the correct approach, does anyone know what is the right approach to have dependencies in a library that can be published with it? should they be published with it at all?