6

I'm trying to add moko a dependency to a kotlin multiplataform on gradle.

org.gradle.internal.resolve.ArtifactNotFoundException: Could not find mvvm-livedata-0.9.1-samplessources.jar (dev.icerock.moko:mvvm-livedata:0.9.1). Searched in the following locations: https://dl.bintray.com/icerockdev/moko/dev/icerock/moko/mvvm-livedata/0.9.1/mvvm-livedata-0.9.1-samplessources.jar

it looks like the "-samplessources" part of the link shouldn't be there, but a don't know how to remove it.

enter image description here

enter image description here

enter image description here

Jhonata Ávila
  • 385
  • 1
  • 13
  • Would it be ok for you to download the jar and save it locally? You could tell Maven to use the downloaded version then. – Ely Jan 25 '21 at 21:20
  • I thought about doing that, but this happens on every moko dependency, and i would need add some others dependency of this. And download and install every single one, wouldn't be practical. – Jhonata Ávila Jan 25 '21 at 21:47
  • I have the same problem man. It is not just problem for moko libraries but for many other libraries. I think that this samplesources.jar files are not even needed - it is probably not problem of that libraries but problem of the Gradle plugin itself. I guess that the Gradle plugin is not able to somehow work with some libraries in KMP projects. – Tom Wayne Jan 28 '21 at 12:30
  • See https://youtrack.jetbrains.com/issue/KT-46153. – Raman Apr 17 '21 at 00:19

3 Answers3

16

If someone else is facing a similar problem (with missing your-library-name-samplessources.jar) Usually, this is happening when your multiplatform project tries to consume the library, which doesn't support all the targets you have declared in your project. For example, you have an ios() target, while the library doesn't produce any native artifact. To understand which targets of your projects are not covered by the library, you could try to build your project by calling

./gradlew build  

You will receive a comprehensive error, describing which library variant wasn't found (ios_x64 in my case): enter image description here

KaterinaPetrova
  • 462
  • 4
  • 12
  • FYI, I created https://youtrack.jetbrains.com/issue/KT-46153 as I believe the failure mode people are encountering is misleading. – Raman Apr 17 '21 at 00:18
  • But should it work or just the error is misleading? I have a lib which doesn't support js target, but I still want to build js target, it will just never use code from this lib. Is it possible or not really? – Michał Klimczak May 09 '21 at 20:36
  • @KaterinaPetrova, yours is the best answer so far. Just realized that the new Kotlin Multiplatform version adds new targets for iOS. Just had to republish my library and import into my project and everything works fine. – Scarminio Sep 24 '21 at 10:27
0

I solved deleting jvm target from gradle, looks like moko library not support jvm yet.

versions: kotlin 1.4.21 moko-mvvm-*: 0.9.1

Jhonata Ávila
  • 385
  • 1
  • 13
0

If you started getting this only recently, you might need to explicitly configure Android library variants for publishing:

kotlin {
    android {
        publishLibraryVariants("debug", "release")
    }
    ...
}

or

kotlin {
    android {
        publishAllLibraryVariants()
    }
    ...
}
deej
  • 1,703
  • 1
  • 24
  • 26