Resolving Android Gradle Plugin and Kotlin Version Compatibility: Migrating from kotlin-stdlib-jre7 to kotlin-stdlib-jdk8

Dec 08, 2025 · Programming · 10 views · 7.8

Keywords: Android | Gradle | Kotlin

Abstract: This article delves into the common Gradle build error "The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher" in Android development. By analyzing a real-world project case, it uncovers the root cause related to the deprecated kotlin-stdlib-jre7 dependency and its conflict with Kotlin Gradle plugin versions. The core solution involves updating the dependency to kotlin-stdlib-jdk8 in the module-level build.gradle and ensuring proper definition of the ext.kotlin_version variable in the project-level build.gradle. Additional configuration tips, such as updating Android Gradle plugin versions and handling React Native project naming conventions, are provided to offer a comprehensive troubleshooting guide for developers.

Problem Background and Error Analysis

In Android development with Kotlin, Gradle build errors frequently occur, especially when project dependencies on Kotlin versions are incompatible with the Android Gradle plugin. The typical error message discussed here is: ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher. The following dependencies do not satisfy the required version: root project 'ui-testing' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.21. This indicates that the Kotlin Gradle plugin version used in the project is below 1.3.0, while the Android Gradle plugin requires at least version 1.3.0.

Core Issue Diagnosis

By examining the provided project code, key issues in the module-level build.gradle file are identified:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

Here, kotlin-stdlib-jre7 is used, which is a deprecated dependency. More critically, when the $kotlin_version variable is not properly defined, Gradle may fall back to an older default version (e.g., 1.2.21), leading to version conflicts with the Android Gradle plugin.

Primary Solution

Based on the best answer (Answer 2), the most effective resolution is:

  1. Update Standard Library Dependency: Replace kotlin-stdlib-jre7 with kotlin-stdlib-jdk8. This is because the jre7 version corresponds to the Java 7 standard library, while modern Android development typically requires Java 8 compatibility. The jdk8 version offers better support for Java 8 APIs and is compatible with newer Kotlin plugin versions.
  2. Properly Define Kotlin Version Variable: In the buildscript block of the project-level build.gradle, ensure that the ext.kotlin_version variable is defined and set to 1.3.0 or higher (e.g., 1.3.10, 1.3.21).

The modified dependency should appear as follows:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

Supplementary Configuration Tips

Other answers provide valuable additional insights:

Implementation Steps and Code Examples

Below are the complete resolution steps:

  1. Modify Project-Level build.gradle:
buildscript {
    ext.kotlin_version = '1.3.21' // Use a compatible version
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0' // Ensure version compatibility
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
<ol start="2">
  • Modify Module-Level build.gradle: Update dependencies and remove unnecessary kotlin-gradle-plugin implementation dependencies (this plugin should only be a classpath dependency at the project level).
  • dependencies {
        // Other dependencies...
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
        // Note: Remove implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
        // because kotlin-gradle-plugin is a build tool plugin and should not be a module dependency
    }
    <ol start="3">
  • Sync and Build: Perform a Gradle sync in Android Studio, then rebuild the project.
  • Deep Dive into Version Compatibility

    Version compatibility between the Android Gradle plugin and Kotlin Gradle plugin is crucial. For instance, Android Gradle plugin 3.2.0+ typically requires Kotlin plugin 1.3.0+. Developers should regularly consult official documentation to ensure recommended version combinations are used. Moreover, the deprecation of kotlin-stdlib-jre7 reflects Kotlin's evolution towards modern Java versions (e.g., JDK 8). Migrating to kotlin-stdlib-jdk8 not only resolves compatibility issues but also leverages new language features.

    Conclusion

    The core solution to the "The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher" error lies in updating the Kotlin standard library dependency and properly defining the version variable. By replacing kotlin-stdlib-jre7 with kotlin-stdlib-jdk8 and setting ext.kotlin_version in the project-level configuration, build system compatibility can be ensured. Combined with other best practices, such as using compatible Android Gradle plugin versions and handling framework-specific conventions, developers can effectively avoid such build errors and enhance development efficiency.

    Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.