.gradle

What is a .gradle file?

Gradle Build Script · Code and data · Gradle Inc. · 2007

A .gradle file is a build script for Gradle, the build tool behind most Android and many Java projects. It declares dependencies, tasks and settings, written in Groovy or Kotlin.

Category
Code and data
MIME type
Type
Plain text
Is a .gradle file safe to open? Caution. A build script runs code during a build and can download dependencies. Review build files from untrusted projects before building them.

What is a .gradle file used for?

build.gradle (Groovy) or build.gradle.kts (Kotlin) tells Gradle how to compile, test and package a project and which libraries to fetch. It is code, executed when you build, not just static config.

Android Studio manages these files for app projects. They are plain text; edit them in the IDE, which understands the Gradle syntax and can sync changes.

How to open a .gradle file

The .gradle format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .gradle file.

Windows

  • Android Studio
  • IntelliJ IDEA
  • VS Code

macOS

  • Android Studio
  • IntelliJ IDEA
  • VS Code

Linux

  • Android Studio
  • IntelliJ IDEA
  • VS Code

.gradle file signature (magic bytes)

Programs recognise a .gradle file by the bytes at the start of the file, not by its name. These are the signatures for Gradle.

Hex signatureOffsetNote
(no fixed signature)0plain text; no fixed magic bytes

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .gradle file?

A .gradle file is a build script for Gradle, the build tool behind most Android and many Java projects. It declares dependencies, tasks and settings, written in Groovy or Kotlin.

How do I open a .gradle file?

Open the project in Android Studio or IntelliJ IDEA, which edit and run Gradle files. Any text editor shows the source.

What is the difference between build.gradle and build.gradle.kts?

Both are Gradle build scripts. build.gradle uses Groovy; build.gradle.kts uses Kotlin, which gives better editor support and type checking.

Why does my Gradle build fail on this file?

Often a dependency version or plugin mismatch. Read the error, check the versions declared in the file, and let the IDE re-sync the project.

Related formats

Sources

Details on this page were checked against authoritative references: