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

No matching variant of project :someModule was found #728

Closed
wezley98 opened this issue Jan 14, 2025 · 7 comments
Closed

No matching variant of project :someModule was found #728

wezley98 opened this issue Jan 14, 2025 · 7 comments
Assignees
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed

Comments

@wezley98
Copy link

Describe the bug
Unable to sync Android project after upgrading to 0.9.0/0.9.1, is working fine with current setup on 0.8.3

Errors

Could not determine the dependencies of task ':network:compileJava'.
> Could not resolve all dependencies for configuration ':network:compileClasspath'.
   > Could not resolve project :crashreporter.
     Required by:
         project :network
      > No matching variant of project :crashreporter was found. The consumer was configured to find a library for use during compile-time, compatible with Java 17, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'debugApiElements' declares a library for use during compile-time, preferably optimized for Android:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
          - Variant 'debugRuntimeElements' declares a library for use during runtime, preferably optimized for Android:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
          - Variant 'debugSourcesElements' declares a component for use during runtime, packaged as a jar, preferably optimized for Android, and its dependencies declared externally:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
          - Variant 'koverArtifact':
              - Incompatible because this component declares a component for use during 'kover' and the consumer needed a component for use during compile-time
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'koverArtifactCustom':
              - Incompatible because this component declares a component for use during 'kover' and the consumer needed a component for use during compile-time
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'koverArtifactDebug':
              - Incompatible because this component declares a component for use during 'kover' and the consumer needed a component for use during compile-time
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'koverArtifactRelease':
              - Incompatible because this component declares a component for use during 'kover' and the consumer needed a component for use during compile-time
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'koverEmptyArtifact':
              - Incompatible because this component declares a component for use during 'kover' and the consumer needed a component for use during compile-time
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseApiElements' declares a library for use during compile-time, preferably optimized for Android:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
          - Variant 'releaseRuntimeElements' declares a library for use during runtime, preferably optimized for Android:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
          - Variant 'releaseSourcesElements' declares a component for use during runtime, packaged as a jar, preferably optimized for Android, and its dependencies declared externally:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)

Expected behavior
Project can sync after upgrading kover from 0.8.3 -> 0.9.1

Reproducer
I believe it's related to this code change in 0.9.0 https://github.com/Kotlin/kotlinx-kover/pull/680/files

Environment

  • Kover Gradle Plugin version: 0.8.3 -> 0.9.0/0.9.1
  • Gradle version: 8.12
  • Kotlin project type: Kotlin/Multiplatform + Android]
@wezley98 wezley98 added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Jan 14, 2025
@shanshin
Copy link
Collaborator

Hi, is your project closed source?

If so, we need more information.

  • is Kover plugin applied in :network project?
  • is Kover plugin applied in :crashreporter project?
  • if you completely remove the use of Kover from everywhere (delete all mentions of the plugin), does the error reproduce?

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Jan 14, 2025
@wezley98
Copy link
Author

wezley98 commented Jan 14, 2025

@shanshin Yes closed source unfortunately, but I can share more details.

root.build.gradle.kts

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.parcelize) apply false
    alias(libs.plugins.kotlin.serialization) apply false
    alias(libs.plugins.android.junit5) apply false
    alias(libs.plugins.google.services) apply false
    alias(libs.plugins.firebase.crashlytics) apply false
    alias(libs.plugins.firebase.perf) apply false
    alias(libs.plugins.androidx.baselineprofile) apply false
    alias(libs.plugins.firebase.test.lab) apply false
    alias(libs.plugins.kover)
    alias(libs.plugins.gradle.doctor)
}

kover {
    merge {
        val excludedModules = listOf(
            "snapshots-roborazzi",
            "contract-test",
            "baselineprofile",
            "kover",
            "macrobenchmark",
            "ui-tests"
        )

        allProjects {
            it.name !in excludedModules && it.buildFile.exists()
        }

        createVariant("custom") {
            add("debug", optional = true)
            add("uatDebug", optional = true)
        }
    }

    reports {
        filters {
            excludes {
                androidGeneratedClasses()
                classes(
                    "*.extensions.*", "*.interfaces.*", "*.ParameterProvider.*", "*.previewproviders.*", "*.mock.*"
                )
                packages("*.di", "*.ext")
                annotatedBy("androidx.compose.ui.tooling.preview.Preview")
                annotatedBy("androidx.compose.runtime.Composable")
            }
        }
        verify {
            rule("Minimal line coverage rate in percents") {
                groupBy = GroupingEntityType.APPLICATION
                minBound(20)
            }
            rule("Branch Coverage") {
                minBound(15, CoverageUnit.BRANCH, AggregationType.COVERED_COUNT)
            }
        }
    }
}

All other modules such as crashreporter etc, are either jvm or KMP or Android all kotlin code.

Plugins Used

AGP - 8.8.0
Kotlin - 2.1.0
Gradle 8.12.0

as said this works fine on Kover 0.8.3, only breaks when switching to 0.9.0+

@shanshin
Copy link
Collaborator

Very interesting. As I see from the configuration, :network project should not have additional kover dependencies.

Please try to remove Kover plugin from the project and rebuild it.

@wezley98
Copy link
Author

wezley98 commented Jan 14, 2025

@shanshin Yes, it's strange.

kover plugin is only used in root build.gradle.kts there is no reference in either :crashreporter (Android) or :network (kotlin jvm) modules, or any other modules beyond the root build file.

:crashreporter/build.gradle.kts

plugins {
    id("com.ournamespace.android.library") // Custom Convention Plugin
    id("com.ournamespace.kotlin.android") // Custom Convention Plugin
    alias(libs.plugins.android.junit5)
}

android {
    namespace = "com.ournamespace.crashreporter"
}

dependencies {
    implementation(projects.interfaces)
    implementation(projects.logging)

    implementation(platform(libs.firebase.bom))
    implementation(libs.firebase.analytics)
    implementation(libs.firebase.crashlytics)

    implementation(platform(libs.koin.bom))
    implementation(libs.koin.core)

    testImplementation(libs.junit5.api)
    testRuntimeOnly(libs.junit5.engine)
    testImplementation(libs.test.mockk)
    testImplementation(libs.kotlin.test)
}

network/build.gradle.kts

plugins {
    id("com.ournamespace.kotlin.jvm") // Custom Convention Plugin
    alias(libs.plugins.kotlin.serialization)
}

tasks.test {
    useJUnitPlatform()
}

dependencies {
    implementation(projects.di)
    implementation(projects.navigation)
    implementation(projects.interfaces)
    implementation(projects.login.loginInterface)
    implementation(projects.login.login)
    implementation(projects.logging)
    implementation(projects.common)
    implementation(projects.crashreporter)

    implementation(platform(libs.arrow.bom))
    implementation(libs.kotlin.serialization)
    implementation(platform(libs.koin.bom))
    implementation(libs.koin.core)
    implementation(platform(libs.opentelemetry.bom))
    implementation(libs.opentelemetry.api)
    implementation(libs.opentelemetry.sdk)
    implementation(libs.opentelemetry.extension.kotlin)
    implementation(libs.arrow.core)

    implementation(libs.kotlin.datetime)

    implementation(platform(libs.ktor.bom))
    implementation(libs.ktor)
    implementation(libs.ktor.logging)
    implementation(libs.ktor.content.negotiation)
    implementation(libs.ktor.serialization.json)
    implementation(libs.ktor.client.android)
    implementation(libs.coil.networking.ktor)
    implementation(libs.opentelemetry.ktor)
    testImplementation(libs.ktor.client.mock)

    testImplementation(libs.junit5.api)
    testRuntimeOnly(libs.junit5.engine)
    testImplementation(libs.test.mockk.kotlin)
    testImplementation(libs.koin.test)
    testImplementation(libs.kotlin.coroutines.test)
}

Entire Project search:

Image

@wezley98
Copy link
Author

To confirm incase I read your comment wrong, I tried removing kover from the project. and it still has the same error :)

Let me investigate our side, I don't understand what's happening now!

@wezley98
Copy link
Author

Fixed, Sorry it was our issue. You can't bring an Android Module into a JVM Module.

Removing the implementation(projects.crashreporter) from :network fixed it. Wasn't been used anyway.

It is strange how kover v0.8.3 was protecting us from the error though 🤦

Feel free to close this issue. Thanks for the pointers.

@shanshin
Copy link
Collaborator

It is strange how kover v0.8.3 was protecting us from the error though 🤦

This is an unpleasant feature of Gradle.

When a dependency is searched for, all artifacts with an intersecting set of attributes are searched.
If no such artifacts are found, then the first available artifact is taken, which does not have any attributes in common with the dependency.

Thus, for implementation(projects.crashreporter) a Kover artifact was resolved (It's good that in your case it didn't lead to problems).
See similar problem gradle/gradle#27019

It was in order for Kover not to mask dependency issues that these changes were made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: waiting for clarification Status: additional information required to proceed
Projects
None yet
Development

No branches or pull requests

2 participants