Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplatform ArtifactNotFouundException #34

Closed
andyburris opened this issue Aug 29, 2020 · 20 comments
Closed

Multiplatform ArtifactNotFouundException #34

andyburris opened this issue Aug 29, 2020 · 20 comments

Comments

@andyburris
Copy link

I'm trying to import com.michael-bull.kotlin-result:kotlin-result:1.1.8 in the commonMain source set in a multiplatform project, but the gradle build is failing with this stacktrace:

Gradle import errors
project ':web': Unable to build Kotlin project configuration
Details: org.gradle.internal.operations.BuildOperationQueueFailure: There was a failure while populating the build operation queue: Could not find kotlin-result-1.1.8-samplessources.jar (com.michael-bull.kotlin-result:kotlin-result:1.1.8).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/michael-bull/kotlin-result/kotlin-result/1.1.8/kotlin-result-1.1.8-samplessources.jar
Caused by: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotlin-result-1.1.8-samplessources.jar (com.michael-bull.kotlin-result:kotlin-result:1.1.8).Searched in the following locations:
https://repo.maven.apache.org/maven2/com/michael-bull/kotlin-result/kotlin-result/1.1.8/kotlin-result-1.1.8-samplessources.jar

I'm using the same dependency in another (JVM-only) project and it works perfectly. Is there something I'm missing with multiplatform configuration that will solve this? Thanks!

@andyburris andyburris changed the title Multiplatform ArtifactNot Multiplatform ArtifactNotFouundException Aug 29, 2020
@michaelbull
Copy link
Owner

It seems to be looking for an artifact with a samplessources classifier, which I've never heard of or seen produced. Not sure about this.

@Munzey
Copy link
Contributor

Munzey commented Aug 30, 2020

Something else to note, what targets have you specified for your mpp build?
You mentioned a project/module called :web:
Should be mentioned that while kotlin-result is now an mpp project it currently only builds artifacts for jvm based mpp projects (so jvm and android). There is currently no js target - if thats something you want you could open an issue requesting it or a pull request.

@mattmook
Copy link

mattmook commented Jan 18, 2021

I have been getting similar issue with one of my own projects... as best I can tell this is an issue when the Multiplatform project has a target for android(). The functionality was added to the Jetbrains/android project back in Feb 2020, see JetBrains/android@d311db0

@TomWayne98
Copy link

I have the same issue in my MPP. Sometimes when I add a library to commonMain {} it gives me this error (sample sources.jar not found)...

Do you guys have some solution for this problem?

@michaelbull
Copy link
Owner

I don't know what samplesources.jar is or should be, nor why we would want to publish it, so until somebody can shed some light on what that is I can't give an answer

@Munzey
Copy link
Contributor

Munzey commented Jan 28, 2021

I wonder would this be solved by simply adding the android() target to the mpp build as suggested above.
It could be because we are only providing a jvm() target and there is some weird compatibility with mpp/kmm builds. I would imagine there is some gradle magic to get the jvm target to be recognized correctly, but maybe these projects just expects some metadata included with the android target.

@michaelbull
Copy link
Owner

We've now got released automatically building artifacts for the JS targets, so maybe it's worth just trying the android ones too and seeing if that fixes this problem for people

@Munzey
Copy link
Contributor

Munzey commented Feb 2, 2021

So I had a little investigation into adding the android target. Basically it would mean we could output an aar artifact (android library) that can contain android sdk specific code and resources.

Unfortunately to do it seems like a real pita as you have to add a whole bunch of android sdk configuration to get it to work (due to requiring the android plugin to be added to the build which doesnt exactly play nice with the mpp plugin).
Managed to only find two articles that kind of detail the steps needed:
https://medium.com/vmware-end-user-computing/adding-an-android-target-to-a-kotlin-multiplatform-project-8da72353be14
https://www.desnav.com/how-to-target-ios-android-with-kotlin-for-multi-platform

Still skeptical as to whether this would solve the issue documented here - baffled as to why the jvm target we already provide wouldn't be enough. Also why I'm now reluctant to go down the route of adding this target for all this overhead/boilerplate.

Could someone who has experienced the issue post a link to their affected project?

If it is only happening when you are depending on the kotlin-result lib in an mpp project with an android() target, how do you have the kotlin-result dependency defined? I wonder if its an issue if you have the dependency set to api instead of implementation 🤔

Any projects you can point to here would be a great help @mattmook @TomWayne98 @andb3

@toomanyeduardos
Copy link

just to back up this issue. I'm also seeing this.
The error, on android, is:
Failed to resolve: kmmsharedmodule-0.0.1-SNAPSHOT-samplessources

I have tried to import my library as implementation and as api without any success.
The kmmsharedmodule's gradle file has this for kotlin and android:

kotlin {
    android()
    ios {
        binaries {
            framework {
                baseName = "kmmsharedmodule"
            }
        }
    }
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            }
        }
        val iosMain by getting
        val iosTest by getting
    }
}

I tried changing android to this, but it didn't help either:

    android {
        publishLibraryVariantsGroupedByFlavor = true
    }

I'm currently trying to make this work using the gradle task of publishToMavenLocal

any suggestions?
Thank you!

@michaelbull
Copy link
Owner

@toomanyeduardos as posted by @Munzey, providing an example repository in which you depend on kotlin-result and encounter the missing artifact exception will help us get one step closer as we can then reliably reproduce it.

@Munzey
Copy link
Contributor

Munzey commented Feb 9, 2021

also we havent published the iOS artifact yet (see #23 ) so trying to use kotlin-result in common dependencies in a kmm project where you have iOS target defined is going to fail.

@Shabinder

This comment has been minimized.

@michaelbull

This comment has been minimized.

@Shabinder

This comment has been minimized.

@Shabinder
Copy link

Shabinder commented Apr 16, 2021

@michaelbull Hey as I said earlier , I was facing same issue with my library and today I fixed it , So I tried to test your project too as I hoped I could maybe help.

But after adding a dependency on this Lib it compiled successfully.
I have jvm,js,androidTarget as of now in my project where I tested.

If Anybody could share a reproducer , I am more than happy to help and even create a PR if i could fix the issue

PS: if you want to add an Android Target too , I can do that and then maybe those who are facing the issue can test again, adding android target in my project fixed the Issue too

@michaelbull
Copy link
Owner

Thanks @Shabinder - knowing that you can depend on this library from an android project without problems is very useful to know 👍. I am tempted to close this issue going forward until somebody submits a reproducible case, as I still can't exactly diagnose the issue reported in the OP on my own computer nor can I find any information as to what this "sourcesjar" thing is.

@Shabinder
Copy link

I can confirm one more thing sourcesjar issue happens if the lib doesn't have all targets which your projects targets.

@rocketraman
Copy link

rocketraman commented Apr 17, 2021

I ran into this issue with mockk also. FYI, I created https://youtrack.jetbrains.com/issue/KTIJ-10769.

@moeindev
Copy link

Anyone found a solution for this problem? I'm having the same problem trying to import my kmm library into my android project!

@michaelbull
Copy link
Owner

@moeindev this is a general Kotlin MPP problem, see: https://youtrack.jetbrains.com/issue/KTIJ-10769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants