.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.

What opens 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.

Windows

  • Android Studio
  • IntelliJ IDEA
  • VS Code

macOS

  • Android Studio
  • IntelliJ IDEA
  • VS Code

Linux

  • Android Studio
  • IntelliJ IDEA
  • VS Code

Open a .gradle file step by step

  1. Confirm the file really is a .gradle. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with Android Studio or IntelliJ IDEA.
  3. On Mac, use Android Studio or IntelliJ IDEA.
  4. On Linux, try Android Studio or IntelliJ IDEA.
  5. Still stuck? Search for a dedicated Gradle viewer rather than a generic one.

Why can't I open my .gradle file?

Almost always because no installed app understands Gradle. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .gradle at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

Gradle has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.

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. How sources are ranked and what is deliberately left out is set out in the methodology.