Gradle "KotlinReflectionNotSupportedError" - Fix kotlin-reflect in CI
Code used Kotlin reflection, but the kotlin-reflect library is not on the runtime classpath. The base Kotlin stdlib ships only minimal reflection; full reflection needs the separate kotlin-reflect artifact, which is missing here.
What this error means
A test or app run throws kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath. It compiles fine; it fails at runtime.
kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation
is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:...)Common causes
kotlin-reflect not on the runtime classpath
Something (Jackson Kotlin module, a framework, or your code) calls full Kotlin reflection, but org.jetbrains.kotlin:kotlin-reflect is not a declared dependency, so it is absent at runtime.
Version skew between stdlib and reflect
If kotlin-reflect is present but at a different version than the Kotlin stdlib, reflection can still fail to initialize. They must match.
How to fix it
Add kotlin-reflect matching your Kotlin version
Declare the reflect artifact so it is on the runtime classpath, at the same version as the stdlib.
dependencies {
implementation(kotlin("reflect")) // matches the Kotlin plugin version
}Confirm it is actually on the runtime classpath
Check the runtime configuration resolves kotlin-reflect at the expected version.
./gradlew :app:dependencies --configuration runtimeClasspath | grep kotlin-reflectHow to prevent it
- Add
kotlin("reflect")whenever code or a library uses full Kotlin reflection. - Keep kotlin-reflect and the Kotlin stdlib on the same version (the Kotlin plugin aligns them).
- Cover reflection-using code paths in tests so the missing jar surfaces in CI, not production.