Skip to content

'variantName' property has null with Android Gradle Library Plugin for KMP #772

@xVemu

Description

@xVemu

Describe the bug
I have gradle module with Android Gradle Library Plugin for KMP.
I've configured hostTests (aka unit tests).
I tried to apply kover plugin, but got the following error.

It's weird, because in afterEvaluate block variantName is not null

afterEvaluate {
    val task = tasks.withType<AndroidUnitTest>().single()

    task.variantName // it's not null
}

Errors

Stacktrace
Caused by: kotlinx.kover.gradle.plugin.commons.KoverCriticalException: Kover error: Non-nullable 'variantName' property has `null` value in dynamic bean over 'task ':components:testAndroidHostTest''
Please create an issue in Kover Gradle Plugin repository: https://github.com/Kotlin/kotlinx-kover/issues
	at kotlinx.kover.gradle.plugin.util.DynamicBean.value(DynamicBean.kt:38)
	at kotlinx.kover.gradle.plugin.locators.KotlinMultiPlatformLocatorKt$locateAndroidLibrary$tests$1.isSatisfiedBy(KotlinMultiPlatformLocator.kt:94)
	at kotlinx.kover.gradle.plugin.locators.KotlinMultiPlatformLocatorKt$locateAndroidLibrary$tests$1.isSatisfiedBy(KotlinMultiPlatformLocator.kt:93)
	at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$1.lambda$isSatisfiedBy$0(DefaultCollectionCallbackActionDecorator.java:62)
	at org.gradle.internal.code.DefaultUserCodeApplicationContext$CurrentApplication.reapply(DefaultUserCodeApplicationContext.java:110)
	at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$1.isSatisfiedBy(DefaultCollectionCallbackActionDecorator.java:62)
	at org.gradle.api.internal.collections.CollectionFilter.filter(CollectionFilter.java:49)
	at org.gradle.api.internal.collections.CollectionFilter$1.execute(CollectionFilter.java:60)
	at org.gradle.api.internal.collections.CollectionFilter$1.execute(CollectionFilter.java:62)
	at org.gradle.internal.ImmutableActionSet$SetWithManyActions.execute(ImmutableActionSet.java:329)
	at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:280)
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.doAdd(DefaultNamedDomainObjectCollection.java:125)
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.tryCreate(DefaultNamedDomainObjectCollection.java:1008)
	... 219 more

Expected behavior
Gradle project should successfully sync.

Reproducer

build.gradle.kts

androidLibrary {
    namespace = "..."
    compileSdk = libs.versions.android.sdk.compile.get().toInt()
    minSdk = libs.versions.android.sdk.min.get().toInt()

    androidResources.enable = true

    withHostTest {
        isIncludeAndroidResources = true
    }
} 

Environment

Metadata

Metadata

Assignees

Labels

BugBug issue typeS: untriagedStatus: issue reported but unprocessed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions