https://kotlinlang.org logo
Title
j

José González Gómez

04/30/2021, 11:27 AM
Hi, I'm having a problem with
kotest
and
Android Studio
in a Kotlin multiplatform project. After adding the
kotest
dependencies to
build.gradle.kts
and reloading the project I get the following warning (not even an error):
Warning:<i><b>project ':partnerSDK': Unable to build Kotlin project configuration</b>
Details: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotest-runner-junit5-4.4.3-samplessources.jar (io.kotest:kotest-runner-junit5:4.4.3).
Searched in the following locations:
    <https://repo.maven.apache.org/maven2/io/kotest/kotest-runner-junit5/4.4.3/kotest-runner-junit5-4.4.3-samplessources.jar></i>
This seems to cause
Android Studio
to stop working, and I'm no longer able to use code completion, or even run unit tests. This makes test creation extremely painful. If I manually create a test I'm able to run it using
./gradlew test
, so this is clearly not a problem with my configuration or Gradle... Has anybody faced this problem? Do you know how to solve it?
w

wasyl

04/30/2021, 11:33 AM
this is clearly not a problem with my configuration or Gradle.
Not necessarily — I’m not sure but I recall Android Studio fetching more artifacts than absolutely necessary when syncing. It might be that the configuration is off, but
test
task is not going through the wrong path. I’m not saying it’s definitely the case, just that you may want to look into some custom logic around dependencies, repositories and artifacts, if you have it
-samplessources
is a weird artifact though. Do you have the same problem with Kotest 4.4.0? This is what we’re using with Android Studio without issues
j

José González Gómez

04/30/2021, 12:04 PM
Yes, I have tried with several Kotest versions, with no success
I have just tried with
4.4.0
, same error
Warning:<i><b>project ':partnerSDK': Unable to build Kotlin project configuration</b>
Details: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotest-runner-junit5-4.4.0-samplessources.jar (io.kotest:kotest-runner-junit5:4.4.0).
Searched in the following locations:
    <https://repo.maven.apache.org/maven2/io/kotest/kotest-runner-junit5/4.4.0/kotest-runner-junit5-4.4.0-samplessources.jar></i>
w

wasyl

04/30/2021, 12:07 PM
In that case I’d suspect something in your configuration or Android Studio 🤔 I don’t see
-samplessources
anywhere in the downloaded artifacts
j

José González Gómez

04/30/2021, 12:26 PM
any idea where to look?
w

wasyl

04/30/2021, 12:27 PM
any custom build logic related to versions, artifacts, dependencies. Maybe custom plugins? I don’t know honestly. I’d maybe search for
samplessources
in all places scope (so also libraries)
Or maybe for just
samples
? Maybe some plugin is trying to fetch samples instead of sources and accidentaly does that for kotest as well?
j

José González Gómez

04/30/2021, 12:36 PM
I'll take a look and see if I find anything... thanks a lot for your help!
👍 1
m

Manuel Luis Padilla

05/01/2021, 11:24 AM
Hi, I didn't experience that specific problem, recently I also had a struggle where I cloned a repository to a new computer and Android Studio was unable to run my tests, but
./gradlew test
would work. I deleted the
.idea/
folder and let Android Studio rebuild it. The problem never came back 🤷 . Obviously it would be interesting to know what went wrong, but if you are really stuck maybe you could try something along those lines and see if it's just a dirty state of Android Studio.
j

José González Gómez

05/03/2021, 7:27 AM
I finally found the problem:
kotest
doesn't seem to support
ios_x64
* What went wrong:
Execution failed for task ':partnerSDK:compileTestKotlinIosX64'.
> Could not resolve all files for configuration ':partnerSDK:iosX64TestCompileKlibraries'.
   > Could not resolve io.kotest:kotest-runner-junit5:4.4.0.
     Required by:
         project :partnerSDK
      > No matching variant of io.kotest:kotest-runner-junit5:4.4.0 was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' but:
          - Variant 'commonMainMetadataElements-published' capability io.kotest:kotest-runner-junit5:4.4.0 declares a usage of 'kotlin-api' of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64')
          - Variant 'jvmApiElements-published' capability io.kotest:kotest-runner-junit5:4.4.0 declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64')
          - Variant 'jvmRuntimeElements-published' capability io.kotest:kotest-runner-junit5:4.4.0 declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64')
          - Variant 'metadataApiElements-published' capability io.kotest:kotest-runner-junit5:4.4.0:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_x64')
I found this in SO: https://stackoverflow.com/a/66262558/2876231
🤔 both
kotest-assertions-core
and
kotest-property
seem to have an
iosx64
variant, but not
kotest-runner-junit5
... can
kotest
be used in a Kotlin Multiplatform Mobile project?