I am having an issue with my multiplatform library...
# multiplatform
r
I am having an issue with my multiplatform library where I build an aar which is resolving correctly but it’s dependecies are not being resolved. Is there any way to transitively add depedencies while using implementation with a aar file inside the libs folder in android?
b
Yes, declare them as api() as opposed to implementation ()
r
I tried that but it says
Copy code
Supplied String module notation 'libs/AddressLibrary-android-1.0-SNAPSHOT.aar' is invalid.
b
Because it is 😀 how are you declaring your transitive dependencies?
r
Like this
Copy code
api('libs/AddressLibrary-android-1.0-SNAPSHOT.aar') {
        transitive = true
    }
b
Yeah, that's bullshit. You should never hard code fs paths
r
Than how should I do it. This was how implementation was being done 😅
b
If that dependency is a module in your project, declare it as api(project("libsAddressLibrary"))
r
It’s actually an aar file
b
You mean it's not coming from maven central or some other repo?
I.e. you just built and copied over aar file?
r
Kind of but not just aar. I copied all the files inside maven local for the library for android
b
Yeah, no wonder it doesn't work. Just publish your lib to maven local and add it as repository to your app. Then declare a dependency as usual implementation ("groupnameversion")
Alternatively google about gradle included builds and link the two projects together that way.
Here's an included build example for you to explore if you want to go that route https://github.com/mpetuska/kmdc/blob/master/sandbox/settings.gradle.kts#L18
r
So I tried the implementation you said and changed it to api as well like
Copy code
api("me.rahulrawat:AddressLibrary:1.0-SNAPSHOT") {
        transitive = true
    }
Now the library is linked but I still have to redeclare all the dependencies declared inside the library. That is still the pain for me 😅
b
You're confusing your dependencies. You declare transitive dependencies in the library as api, but in your app as implementation
r
So are you saying that for the following excerpt
Copy code
val commonMain by getting {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"){
                    version {
                        strictly(coroutinesVersion)
                    }
                }
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")

                implementation("io.ktor:ktor-client-core:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization:$ktorVersion")
                implementation("io.ktor:ktor-client-logging:$ktorVersion")

                implementation("com.squareup.sqldelight:runtime:$sqlDelightVersion")
                implementation("com.squareup.sqldelight:coroutines-extensions:$sqlDelightVersion")

                implementation("org.kodein.di:kodein-di:$kodeinVersion")
            }
        }
I have to declare all the implementation to api with transitive true so I don’t have to reinclude them inside android app?
b
Yes and no
Transitive true is not required
r
It works finally. I don’t know how to thank you now man. Can’t thank you enough 😄
b
Sweet, glad to hear you got it sorted.
🙌 2