How to change the Kotlin version in Android Studio for your project

Share
A laptop screen displaying Android Studio IDE with a Gradle file open showing Kotlin version declaration.

To change the Kotlin version in your Android Studio project, you need to update the version declaration in your Gradle build files. This update controls which Kotlin compiler and libraries your project uses. After making the change, syncing and rebuilding the project applies it and helps catch any compatibility issues early.

Where does Android Studio specify the Kotlin version?

Android Studio projects declare the Kotlin version primarily in their Gradle build files. The main location is the project-level build.gradle file (or build.gradle.kts if using Kotlin DSL). Inside the buildscript's dependencies block, you'll find the Kotlin Gradle plugin version specified like this:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.x.x"

This version determines the Kotlin compiler and tooling used during your build.

At the module or app level, the build.gradle file usually declares Kotlin library dependencies like kotlin-stdlib. These dependencies should match the Kotlin plugin version or refer to a shared variable defined at the project level.

New Android Studio projects now use a Gradle version catalog instead. In that setup, the Kotlin version lives in gradle/libs.versions.toml, in an entry such as kotlin = "2.x.x", and the root build.gradle.kts applies the plugin through the plugins block, for example alias(libs.plugins.kotlin.android) apply false. Older projects use the buildscript classpath line shown above. Check which style your project uses before editing.

Android Studio IDE window focused on the project-level build.gradle file highlighting the Kotlin version declaration.

How do I change the Kotlin version in my build.gradle files?

  1. Open the project-level build.gradle file located in your project's root folder.
  2. Find the buildscript block and inside its dependencies, locate the Kotlin Gradle plugin line, which looks like this:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.x.x"
  1. Replace the version number with the Kotlin version you want to use. For example:
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.x.x"
  1. Open your app-level (or module-level) build.gradle file.
  2. If your project uses a version catalog, simply update the kotlin entry in libs.versions.toml instead of steps 1 to 3. You no longer need to declare kotlin-stdlib yourself, because the Kotlin Gradle plugin adds it automatically. If an old explicit kotlin-stdlib line exists, remove it or keep it in sync:
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.x.x"

Update these to match the Kotlin version you set in the project-level file. If your project uses a shared version variable, update that variable instead.

  1. Save all changes.

Ensure the Kotlin version you choose is compatible with your Android Gradle Plugin and Gradle versions to avoid build failures.

A developer updating the Kotlin plugin version in the build.gradle file inside Android Studio.

How to sync and rebuild your project after changing Kotlin version

  1. After updating the Kotlin version in your Gradle files, click the "Sync Project with Gradle Files" button in the Android Studio toolbar. This applies your changes by re-importing the Gradle setup.
  2. Once the sync completes successfully, rebuild your project by selecting Build > Rebuild Project from the menu.
  3. Monitor the Build window for any errors or warnings related to Kotlin or plugin compatibility.

If the build succeeds, your Kotlin version change is active. If errors appear, they might be due to version conflicts, deprecated APIs, or incompatible plugins.

Android Studio IDE toolbar showing the Sync Project with Gradle Files button being clicked after Kotlin version update.

If you move to Kotlin 2.0 or later and use Jetpack Compose, also apply the Compose compiler Gradle plugin (org.jetbrains.kotlin.plugin.compose) with the same version, and update KSP to a version that matches your Kotlin release.

What common problems happen after changing Kotlin version and how to fix them

After updating Kotlin, you might encounter these issues:

  • Gradle sync failures: These often happen because the Kotlin plugin version doesn't match your Gradle or Android Gradle Plugin (AGP) versions. Check official Kotlin and AGP compatibility and update Gradle or AGP if needed.
  • Deprecated syntax or APIs: New Kotlin versions may deprecate older language features or standard library functions. Review warnings in your code and update syntax accordingly.
  • Plugin incompatibility: Some third-party Gradle plugins might not support the new Kotlin version yet. Either update those plugins to their latest versions or temporarily revert your Kotlin version.
  • Dependency conflicts: If your project depends on Kotlin libraries with fixed versions, make sure they align with your Kotlin plugin version to avoid runtime errors.

If problems persist, try cleaning the project (Build > Clean Project) and invalidating caches in Android Studio (File > Invalidate Caches / Restart). This can resolve lingering build issues.

How to confirm the Kotlin version was updated successfully

To verify your project uses the updated Kotlin version:

  • Open the Gradle tool window in Android Studio and expand your project. Under Tasks > kotlin, run the kotlinCompile (or compileKotlin) task. The Build window usually shows the Kotlin compiler version used.
  • Run ./gradlew buildEnvironment or check the Gradle sync output to see which Kotlin Gradle plugin version was resolved.
./gradlew buildEnvironment
  • Finally, review the build logs during compilation. They typically include the Kotlin compiler version.

If these confirm the version matches what you set in your build.gradle files, your update succeeded.

Conclusion

Changing the Kotlin version in Android Studio requires updating the version in your Gradle build files, then syncing and rebuilding your project. Always check that your Kotlin version is compatible with your Android Gradle Plugin and Gradle versions to avoid build errors. After the update, verify the change through build output or Gradle tasks to ensure your project uses the correct Kotlin compiler and libraries. This careful approach helps maintain project stability and access to the Kotlin features you need.

Frequently Asked Questions

Can I use any Kotlin version with any Android Gradle Plugin version?

No. Kotlin versions must be compatible with your Android Gradle Plugin version. Using incompatible versions can cause build failures or unexpected errors. Always check official compatibility before upgrading.

What happens if I update Kotlin but forget to update the stdlib dependency version?

In current setups the Kotlin Gradle plugin adds a matching standard library automatically, so you usually don’t declare it. If an older project pins kotlin-stdlib explicitly to a different version, you can get warnings or subtle runtime issues, so remove the explicit line or keep it aligned.

How do I handle deprecated Kotlin features after upgrading the version?

Look for deprecation warnings in your code and update the syntax or APIs accordingly. The Kotlin compiler usually suggests replacements or migration paths for deprecated features.

Is it safe to downgrade Kotlin version if the new one causes issues?

Yes. You can revert the Kotlin version in your Gradle files to a previous stable version, then sync and rebuild. Keep in mind that code using newer Kotlin features may not compile with older versions.

Read more