Kotlin
Compilation Error
Metadata Version
Software Development
Programming

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

This error means a dependency in your project was compiled with a newer Kotlin compiler than the one your project uses. In this case, the dependency was compiled with Kotlin 1.5.x (metadata version 1.5.1) but your project uses Kotlin 1.1.x (which expects metadata version 1.1.16). The fix is to update your project's Kotlin version to match or exceed the version used by your dependencies. Kotlin maintains forward compatibility — newer compilers can read older metadata, but older compilers cannot read newer metadata.

Understanding the Error

Kotlin compiles classes with metadata that describes their Kotlin-specific features (nullable types, default parameters, extension functions, etc.). Each Kotlin version writes a specific metadata version:

Kotlin VersionMetadata Version
1.1.x1.1.x
1.3.x1.1.13
1.4.x1.4.x
1.5.x1.5.1
1.6.x1.6.0
1.7.x1.7.0
1.8.x1.8.0
1.9.x1.9.0

When the Kotlin compiler reads a class with metadata version higher than what it supports, it produces this error.

Update your project's Kotlin version to match the dependency:

Gradle (Kotlin DSL)

kotlin
1// build.gradle.kts
2plugins {
3    kotlin("jvm") version "1.9.22"  // Update to latest stable
4    kotlin("android") version "1.9.22"
5}

Gradle (Groovy DSL)

groovy
1// build.gradle (project-level)
2buildscript {
3    ext.kotlin_version = '1.9.22'  // Update here
4    dependencies {
5        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
6    }
7}
8
9// build.gradle (module-level)
10dependencies {
11    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
12}

Maven

xml
1<properties>
2    <kotlin.version>1.9.22</kotlin.version>
3</properties>
4
5<dependencies>
6    <dependency>
7        <groupId>org.jetbrains.kotlin</groupId>
8        <artifactId>kotlin-stdlib</artifactId>
9        <version>${kotlin.version}</version>
10    </dependency>
11</dependencies>
12
13<build>
14    <plugins>
15        <plugin>
16            <groupId>org.jetbrains.kotlin</groupId>
17            <artifactId>kotlin-maven-plugin</artifactId>
18            <version>${kotlin.version}</version>
19        </plugin>
20    </plugins>
21</build>

Fix 2: Downgrade the Dependency

If you cannot update Kotlin (e.g., constrained by another dependency), use an older version of the incompatible library:

groovy
1// Find which dependency causes the conflict
2./gradlew dependencies --configuration compileClasspath | grep kotlin
3
4// Downgrade the problematic library to a version compiled with your Kotlin version
5dependencies {
6    implementation("com.example:library:1.2.0")  // was 2.0.0 (compiled with Kotlin 1.5)
7    // 1.2.0 was compiled with Kotlin 1.1
8}

Fix 3: Android Studio / IntelliJ

In Android Studio, the Kotlin plugin version must match the build script:

  1. Go to FileSettingsLanguages & FrameworksKotlin
  2. Click Update if a newer version is available
  3. Or go to ToolsKotlinConfigure Kotlin Plugin Updates
  4. Sync project with Gradle after updating

Also check that the Kotlin plugin in build.gradle matches:

groovy
plugins {
    id 'org.jetbrains.kotlin.android' version '1.9.22'
}

Diagnosing Which Dependency Causes the Error

bash
1# Gradle: show dependency tree
2./gradlew dependencies --configuration compileClasspath
3
4# Find Kotlin versions in dependencies
5./gradlew dependencies | grep kotlin
6
7# Maven: show dependency tree
8mvn dependency:tree | grep kotlin

Look for libraries that pull in a kotlin-stdlib version higher than your project's:

 
+--- com.example:library:2.0.0
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.31  ← compiled with Kotlin 1.5 +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.61       ← your project uses 1.1 ``` ## Version Alignment Strategy ```groovy // Force all Kotlin dependencies to the same version configurations.all { resolutionStrategy { force "org.jetbrains.kotlin:kotlin-stdlib:1.9.22" force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22" force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22" force "org.jetbrains.kotlin:kotlin-reflect:1.9.22" } } ``` Or use a BOM (Bill of Materials): ```kotlin dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.22")) implementation("org.jetbrains.kotlin:kotlin-stdlib") } ``` ## Common Pitfalls * **Updating Kotlin plugin but not the stdlib**: The Kotlin Gradle plugin version and `kotlin-stdlib` version must match. Updating only one leaves the other at the old version, causing subtle compilation issues or this exact error. * **Transitive dependency pulling in a newer Kotlin version**: A library you depend on may transitively include a newer `kotlin-stdlib`. Use `./gradlew dependencies` to identify it, then either update your Kotlin version or force the stdlib version with `resolutionStrategy`. * **IDE Kotlin plugin version mismatch**: Android Studio and IntelliJ bundle a Kotlin plugin that may differ from your Gradle config. If the IDE shows errors that Gradle does not (or vice versa), update the IDE plugin to match your `build.gradle` Kotlin version. * **Using an old Kotlin version with new Android libraries**: Google's AndroidX and Jetpack Compose libraries are compiled with recent Kotlin versions. Using Kotlin 1.1.x with modern Android libraries is not feasible — you must update to at least the version each library requires. * **Not cleaning the build after upgrading**: Stale compiled classes from the old Kotlin version may linger in the build cache. Run `./gradlew clean` (or **Build** → **Clean Project** in Android Studio) after changing the Kotlin version. ## Summary * The error means a dependency was compiled with a newer Kotlin version than your project uses * Update your Kotlin version in `build.gradle` to match or exceed the dependency's Kotlin version * Use `./gradlew dependencies` to identify which library requires the newer Kotlin version * Keep the Kotlin Gradle plugin, stdlib, and IDE plugin at the same version * Run `./gradlew clean` after upgrading Kotlin to clear stale cached classes * Use `resolutionStrategy.force` or a Kotlin BOM to align all Kotlin dependency versions

Course illustration
Course illustration

All Rights Reserved.