https://kotlinlang.org logo
#android
Title
# android
c

Christy Jacob

06/22/2021, 6:19 PM
Hey everyone, I've successfully published an android library to Maven's Snapshot repo (https://s01.oss.sonatype.org/content/repositories/snapshots/io/appwrite/sdk-for-android/) When I examine the POM file, all the intended dependencies are present as well. So I create a new Android project to consume this library. I add the snapshot repository URL to my project's build.gradle
Copy code
repositories {
    maven {
        url "<https://s01.oss.sonatype.org/content/repositories/snapshots/>"
    }
}
I then add my dependency
Copy code
dependencies {
   implementation("io.appwrite:sdk-for-android:0.0.0-SNAPSHOT")
}
Now I try to sync my Gradle files and I'm faced with this error.
Copy code
Failed to resolve: com.github.franmontiel:PersistentCookieJar:v1.0.1
This is in fact a transitive dependency from my library (https://github.com/appwrite/sdk-for-android/blob/main/library/build.gradle#L71) I'm now forced to add the jitpack maven repo to my example app as well, after which the error disappears.
Copy code
repositories {
    maven {
        url "<https://s01.oss.sonatype.org/content/repositories/snapshots/>"
    }
    maven { url "<https://jitpack.io>" }
}
Is there a way to avoid adding this repository ? My library's pom file already contains this dependency. (https://s01.oss.sonatype.org/content/repositories/snapshots/io/appwrite/sdk-for-android/0.0.0-SNAPSHOT/sdk-for-android-0.0.0-20210617.055649-2.pom). Is there a way for gradle to automatically fetch this dependency without me having to add the jitpack repository ? I would not expect my end users to add an additional repository. Thank you for your help 🙂
c

Casey Brooks

06/22/2021, 6:46 PM
Not really Kotlin, but no, repositories are not resolved transitively, and an artifact is not tied directly to any particular repository. This is intentional, as it helps prevent malware from being spread and allows orgs to configure proxies/caches for safely fetching artifacts form the internet. You have to manually specify every repository you’re pulling dependencies from, in the order they should be checked.
c

Christy Jacob

06/23/2021, 4:33 AM
@Casey Brooks Thank you. That helps a lot.
5 Views