How to run a Gradle Kotlin DSL build task in Android Studio

Oscar de la Hera Gomez
Two flowers that represent Kotlin and Android Studio. Beneath it sits the text "Pre-Build Kotlin Gradle DSL Task."

A step by step guide on running a Kotlin Gradle pre-build task in Android Studio.

Step One: Select a Gradle file

A screenshot of Android Studio highlighting the location of the Gradle files.

Select the Gradle file you wish to run your task in.

Step Two: Add the Task

A screenshot of Android Studio showing a Hello World task in a gradle file.

Add the task to the gradle file, using code similar to the one available below.

Step Three: Test

A screenshot of Android Studio showing the "Hello World" being printed out in the Gradle Build Terminal.

Sync your Gradle, and confirm that the task is ran.

Looking for more information on Gradle Kotlin DSL?

Please consult the Gradle Kotlin DSL primer linked below.

Looking to run a task at any stage of the build ?

Consult our guide below to learn how to run a task at any stage of a Gradle's build.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details