Repository navigation
Labels
Description
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
- Kover Gradle Plugin version: 0.9.3
- Gradle version: 8.14.3
- Kotlin project type: Android Gradle Library Plugin for KMP version 8.13.0
Reacted by Lars Mühlbauer, xDev, Thomas Wirth and Egor Egorov
Activity
Siedlerchr commentedon Dec 17, 2025
Ran into the same issue, happens as soon I add withHostTest {}
G00fY2 commentedon Jan 15, 2026
I there any (temporary) workaround for this?
Edit: Adding this seems to fix the issue for now:
shanshin commentedon Jan 15, 2026
Hi, could you please provide a small reproducer project?
This will help to better understand the source of the issue.
azazellj commentedon Jan 31, 2026
Hello @shanshin.
This is weird, but you can use this project, just put plugins in such order:
if order is the same as in your example, an error does not appear.
ShadowRZ commentedon Feb 4, 2026
@azazellj Tried with what you said but no issues at all, can you really reproduce this problem with the instructions you provided?
Eroad-Egor-Egorov commentedon Mar 8, 2026
Getting the same issue. I am currently migrating project to AGP 9.0 with creating a separate module for Android for full KMP project
Kover 0.9.7
AGP 9.0.0
Eroad-Egor-Egorov commentedon Mar 8, 2026
Actually resolved the issue by removing
withHostTest {}from the configuration on shared moduleShadowRZ commentedon Mar 9, 2026
@Eroad-Egor-Egorov Strange, earlier I tried with my own project without issues, I also can't reproduce this issue with the instructions in #772 (comment)
Can you try to make a minimal reproduction and upload it?
dsrees commentedon Mar 9, 2026
Here is a demo repo which reproduces this issue for me. The key detail is that it uses a SQLDelight database and
expectsa driver for the tests that require a DB connection. TheandroidHostTestprovides anactualJVM in-memory driver for test cases.In
./build.gradle.ktsis the lineapply<KoverGradlePlugin>()which, when uncommented, allows the sync to succeed.Yegorisa commentedon Mar 16, 2026
@ShadowRZ well guess what, the order of the following plugins
matters. If you put the plugins in this exact order, the error disappears. Previously the first two plugins were in opposite places
ShadowRZ commentedon Mar 16, 2026
@dsrees I can reproduce the issue during import using the reproduction you provided, while @Yegorisa was right in that plugin order is significant.
Cc @shanshin I think it should count as a reproduction
Fixed Android multiplatform library support
Fixed Android multiplatform library support in case of the violation …
shanshin commentedon Mar 25, 2026
Fixed in
0.9.8