Introduction: The Familiar Yellow Triangle
Have you ever seen this warning in IntelliJ IDEA or during a Gradle build? It appears, you check build.gradle.kts — and see that the versions match. But the IDE stubbornly continues to highlight with a yellow triangle: "Kotlin plugin version is not the same as library version". Sound familiar?
This is one of the most popular problems on Stack Overflow (thousands of views!). It seems like the system has gone crazy. But in reality, there is a very specific technical reason behind it. In this article, we will not just remove the annoying warning, but also understand how it affects the optimization and performance of your Kotlin project.
The Essence of the Problem: Why Does the Warning Occur If the Versions Match?
Let's break down the anatomy of the error. You write in build.gradle.kts:
plugins { kotlin("jvm") version "1.9.22" apply false}
// In the dependencies section:implementation(kotlin("stdlib", "1.9.22"))Everything seems fair. But Gradle sees two different artifacts:
- Kotlin Gradle Plugin — version 1.9.22 (manages compilation)
- Kotlin Stdlib — version 1.9.22 (runtime library)
The problem is that Gradle can pull in a transitive dependency with a different version of Kotlin. For example, if your project uses the Fuel or Ktor library, they might pull in kotlin-stdlib:1.8.0. As a result, two different versions of the same library end up in the classpath.
The IDE sees a version conflict between the plugin (1.9.22) and one of the libraries (1.8.0) — and issues a warning. Meanwhile, your explicit dependency kotlin("stdlib", "1.9.22") may be overridden by the transitive one.
Diagnostics: How to Find the Culprit?
Before treating, you need to understand where the old version comes from. Use Gradle's built-in tools.
Method 1: Gradle dependencies task
Run in the terminal:
./gradlew dependencies --configuration runtimeClasspathIn the output, find lines containing kotlin-stdlib. You will see something like:
+--- org.jetbrains.kotlin:kotlin-stdlib:1.9.22| \\--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.22+--- com.example:some-library:2.0.0| \\--- org.jetbrains.kotlin:kotlin-stdlib:1.8.0 -> 1.9.22The arrow -> shows that Gradle resolved the conflict in favor of version 1.9.22. But the warning may still remain if the plugin analyzes the original versions.
Method 2: IntelliJ IDEA — Module Settings
Open File → Project Structure → Modules. Select your module and look at the Dependencies tab. All dependencies, including transitive ones, are displayed there. If you see kotlin-stdlib:1.8.0 (or another version) — that is the source of the problem.
4 Ways to Fix the Warning (and Improve Performance)
Now let's move on to the most interesting part — the solutions. Each method affects build optimization and runtime performance.
Method 1: Forced Version Alignment
The most correct approach is to use Kotlin BOM (Bill of Materials). This guarantees that all Kotlin dependencies will be the same version.
// build.gradle.ktsdependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.22")) implementation("org.jetbrains.kotlin:kotlin-stdlib") // Now you don't need to specify the version — it is taken from the BOM}Why is this good for performance? BOM eliminates class duplication in the classpath. If you have two versions of kotlin-stdlib
Blogs
Book Recommendations
Read also
Working with Databases in Go: PostgreSQL and MongoDB for Beginners
How to Add 1 Day to NSDate: 5 Fatal Mistakes for Beginners in Swift
Typical TypeScript Error: property 'value' does not exist on HTMLElement
Microservices in Go: Architecture and Practice for Developers
Collection was modified: how to beat the collection enumeration error