Learning Android Development

Convert Android’s Gradle files from Groovy to Kotlin Step by Step

Transform your initial Android Project Gradle into Kotlin

Picture by Roger Brown on Pexels

When we create a project in Android (Arctic Fox 2020.3.1), we get the default Gradle Script setup for us. There are 3 Gradle files, they are all written in Groovy still.

  1. The settings.gradle
  2. The root project’s build.gradle
  3. The app module’s build.gradle

How nice if it is in Kotlin. Well, let’s convert them to Kotlin using the below step-by-step guide.

Gradle support interoperability of Groovy and Kotlin Gradle file. Hence we can convert them one at a time. Let’s convert them one by one.

Convert the settings.gradle

1. Rename to .kts file

First, just convert the file name from settings.gradle to settings.gradle.kts.

You can do so by selecting the settings.gradle file, then go to Refactor →Rename File.

--

--