question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot choose between the following variants of com.squareup.okio:okio:2.3.0

See original GitHub issue

I just upgraded from okio:2.2.2 to okio:2.3.0 and don’t know how to tell gradle which artifact to use 🤔 Is there a documentation how to declare okio for non kotlin-multiplatform projects?

Could not determine the dependencies of task ':main:kaptDebugKotlin'.
> Could not resolve all task dependencies for configuration ':main:kapt'.
   > Could not resolve com.squareup.okio:okio:1.16.0.
     Required by:
         project :main > com.ryanharter.auto.value:auto-value-moshi:0.4.7 > com.squareup.moshi:moshi:1.8.0
      > Cannot choose between the following variants of com.squareup.okio:okio:2.3.0:
          - jvm-api
          - jvm-runtime
          - metadata-api
        All of them match the consumer attributes:
          - Variant 'jvm-api' capability com.squareup.okio:okio:2.3.0:
              - Unmatched attributes:
                  - Required artifactType 'processed-jar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-api-jars' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
          - Variant 'jvm-runtime' capability com.squareup.okio:okio:2.3.0:
              - Unmatched attributes:
                  - Required artifactType 'processed-jar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-runtime-jars' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
          - Variant 'metadata-api' capability com.squareup.okio:okio:2.3.0:
              - Unmatched attributes:
                  - Required artifactType 'processed-jar' but no value provided.
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'kotlin-api' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'common' but wasn't required.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
cyc1ingsircommented, May 29, 2020

If you go to start.spring.io and configure a project with Gradle Project; Kotlin; Spring Boot 2.3.0; Packaging Jar; Java 11 download the project, unzip it and add implementation("com.squareup.okio:okio:2.6.0") to build.gradle.kts (dependencies) This error will show up when running ./gradlew clean build

* What went wrong:
Execution failed for task ':bootJar'.
> Could not resolve all files for configuration ':productionRuntimeClasspath'.
   > Could not resolve com.squareup.okio:okio:2.6.0.
     Required by:
         project : > com.squareup.okhttp3:okhttp:4.7.2
      > Cannot choose between the following variants of com.squareup.okio:okio:2.6.0:
          - jvm-api
          - jvm-runtime
          - metadata-api
        All of them match the consumer attributes:
          - Variant 'jvm-api' capability com.squareup.okio:okio:2.6.0:

Removing the line with kotlin("kapt") version "1.3.72"doesn’t change anything. Generating a project for SpringBoot version 2.2.7.RELEASE doesn’t show this error.

In the end I was able to solve it with this workaround based on the solution described here: https://github.com/google/protobuf-gradle-plugin/issues/391#issuecomment-609958243

I added this to the end of my build.gradle.kts

configurations.forEach {
  if (it.name.contains("productionRuntimeClasspath")) {
    it.attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "java-runtime"))
  }
}

6reactions
Egorandcommented, Aug 13, 2019

I suspect that the Kotlin Gradle plugin should be doing something similar internally, that should hopefully get fixed in subsequent releases. The workaround looks good, I’m gonna keep this issue open in case somebody else experiences it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot choose between the following configurations of ...
I trying to generate signed apk but i have one problem: Cannot choose between the following configurations of project :instant: - kapt - ......
Read more >
Square Point of Sale App Troubleshooting
Troubleshoot Your Mobile Device. If you notice the Square app isn't acting the way you expect, try the following troubleshooting tips:.
Read more >
Error: Cannot choose between the following variants
Hello, I'm trying to upgrade this project from Spring Boot 2.2.4 to 2.4.3 but now I'm running into a Gradle issue: Script ...
Read more >
MissingDimensionStrategy not working with Hilt Plugin ...
For that we declare the following in the app's build.gradle : ... However we cannot choose between the following variants of project :mylibrary: ......
Read more >
Android consumers can't resolve Android debug variants of ...
However we cannot choose between the following variants of com.example:lib:1.0: - debugApiElements-published - debugRuntimeElements-published ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found