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

Cannot find a version of 'org.jetbrains.kotlinx:atomicfu' that satisfies the version constraints #469

Open
GuilhE opened this issue Sep 3, 2024 · 12 comments
Labels
compiler-plugin Issues related to the atomicfu-compiler-plugin

Comments

@GuilhE
Copy link

GuilhE commented Sep 3, 2024

atomicfu was already on 0.25.0 and working, but suddenly when running for Android I'm getting:

Execution failed for task ':shared:compileDebugKotlinAndroid'.
> Error while evaluating property 'friendPathsSet$kotlin_gradle_plugin_common' of task ':shared:compileDebugKotlinAndroid'.
   > Could not resolve all files for configuration ':shared:debugCompileClasspath'.
      > Could not resolve org.jetbrains.kotlinx:atomicfu:0.25.0.
        Required by:
            project :shared
         > Cannot find a version of 'org.jetbrains.kotlinx:atomicfu' that satisfies the version constraints:
              Dependency path ':shared:unspecified' --> 'org.jetbrains.kotlinx:atomicfu:0.25.0'
              Constraint path ':shared:unspecified' --> 'org.jetbrains.kotlinx:atomicfu:{strictly 0.23.2}' because of the following reason: version resolved in configuration ':shared:debugRuntimeClasspath' by consistent resolution

project build.gradle:

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.android.library) apply false
    alias(libs.plugins.kotlinx.compose) apply false
    alias(libs.plugins.kotlinx.compose.compiler) apply false
    alias(libs.plugins.kotlinx.atomicfu) apply false
}

shared build.gradle:

plugins {
    ...
    alias(libs.plugins.kotlinx.atomicfu)
    //id("org.jetbrains.kotlinx.atomicfu") version "0.25.0" // -> this fails too
}

Screenshot 2024-09-03 at 11 08 03

No problem running for iOS, Desktop and Wasm.

ps: I've checked if any of other dependencies uses atomicfu and they do, but none on 0.23.2 they are on 0.24.0. And as I said it was already working. The only change was bumping Kotlin version, but I've rolledback and the problem still remains. Cleaned all caches too. 🤷🏼

@GuilhE
Copy link
Author

GuilhE commented Sep 3, 2024

I've found this:

Screenshot 2024-09-03 at 11 48 36
Screenshot 2024-09-03 at 11 51 23

My project has 2 modules shared and shared-ui (depends on first). Atomicfu is used by the first:

.shared-appleMain.cinteropLibraries.json:

[
  {
    "moduleId": "org.jetbrains.kotlinx:atomicfu:0.25.0",
    "file": ".../.kotlin/metadata/kotlinTransformedCInteropMetadataLibraries/org.jetbrains.kotlinx-atomicfu-0.25.0-iosMain-cinterop/org.jetbrains.kotlinx_atomicfu-cinterop-interop-l0JTDg.klib",
    "sourceSetName": "iosMain"
  }, ...
]

.shared-ui-appleMain.cinteropLibraries.json:

[
  {
    "moduleId": "org.jetbrains.kotlinx:atomicfu:0.23.2",
    "file": ".../.kotlin/metadata/kotlinTransformedCInteropMetadataLibraries/org.jetbrains.kotlinx-atomicfu-0.23.2-iosMain-cinterop/org.jetbrains.kotlinx_atomicfu-cinterop-interop-l0JTDg.klib",
    "sourceSetName": "iosMain"
  }, ...
]

Questions:

  1. Where is 0.23.2 coming from?
  2. Why it works for all targets except Android?

@fzhinkin
Copy link
Contributor

fzhinkin commented Sep 3, 2024

@GuilhE could you please share some project where the problem reproduces? It would help a lot with tracking the root cause down.

@GuilhE
Copy link
Author

GuilhE commented Sep 3, 2024

@GuilhE could you please share some project where the problem reproduces? It would help a lot with tracking the root cause down.

Yes, you can try this: https://github.com/GuilhE/WhosNext just bump:

Screenshot 2024-09-03 at 15 05 38

@fzhinkin
Copy link
Contributor

fzhinkin commented Sep 3, 2024

Thanks!

Adding an explicit dependency on atomicfu:0.25.0 to shared's commonMain dependencies seems to solve the issue:

        commonMain.dependencies {
            implementation(libs.kotlinx.coroutines.core)
            implementation(libs.kotlinx.serialization)
            implementation(libs.kmp.settings)
            api(libs.kmp.viewmodel)
            api(libs.kmp.koin.core)
            api(libs.kmp.kermit)
            implementation("org.jetbrains.kotlinx:atomicfu:0.25.0")
        }

But it's unclear to me where the problematic dependency on 0.23.2 is coming from.

@fzhinkin fzhinkin added the compiler-plugin Issues related to the atomicfu-compiler-plugin label Sep 3, 2024
@GuilhE
Copy link
Author

GuilhE commented Sep 3, 2024

Adding an explicit dependency on atomicfu:0.25.0 to shared's commonMain dependencies seems to solve the issue:

If I remember correctly, recently, the dependency configuration was moved from "lib dependency" to "plugin dependency" correct? In other words, it should not be necessary to add it as a commonMain dependency. 🤔

@fzhinkin
Copy link
Contributor

fzhinkin commented Sep 3, 2024

If I remember correctly, recently, the dependency configuration was moved from "lib dependency" to "plugin dependency" correct?

That's correct. And that's how the project got Dependency path ':shared:unspecified' --> 'org.jetbrains.kotlinx:atomicfu:0.25.0'. It's unclear, thought, where the constraint on 0.23.2 is coming from, but explicit dependency on 0.25.0 lifts it off.

@GuilhE
Copy link
Author

GuilhE commented Sep 3, 2024

@fzhinkin I've another project and I've noticed the same atomicfu reference of 0.23.2 version inside .kotlin folder. I've no atomicfu definition in my project. The depencies are:

commonMain.dependencies {
   implementation(compose.runtime)
   implementation(compose.foundation)
   implementation(compose.material3)
   implementation(compose.ui)
}

So, is it compose-multiplatform introducing this problem?

@fzhinkin
Copy link
Contributor

fzhinkin commented Sep 3, 2024

@GuilhE Yes, the dependency on 0.23.2 is indeed from the Compose libraries.

I guess, the problem has something to do with that fact that AtomicFU plugin works only with Kotlin JVM and Multiplatform plugins, but it does not support Android Gradle plugin.

So, I was wrong about

And that's how the project got Dependency path ':shared:unspecified' --> 'org.jetbrains.kotlinx:atomicfu:0.25.0'.

as it should not be configured by the plugin (or, to be more precise, that dependency should only be added to native targets).

I'm yet to figure out how releaseCompileClasspath and other relative configurations are set.

@GuilhE
Copy link
Author

GuilhE commented Sep 4, 2024

Should I submit a request for the compose-multiplatform team to update their version to match the latest atomicfu release while the atomicfu team addresses the dependency issue?

@fzhinkin
Copy link
Contributor

fzhinkin commented Sep 5, 2024

Should I submit a request for the compose-multiplatform team to update their version to match the latest atomicfu release while the atomicfu team addresses the dependency issue?

Updating version in Compose won't solve the problem in general. So I don't think this issue should drive version updates in Compose.

@fzhinkin
Copy link
Contributor

Related issue: #145

@colinrtwhite
Copy link

colinrtwhite commented Oct 2, 2024

Related YouTrack issue: https://youtrack.jetbrains.com/issue/CMP-5831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-plugin Issues related to the atomicfu-compiler-plugin
Projects
None yet
Development

No branches or pull requests

3 participants