Gradle
Gradle Install Gradle build tool using SDKMAN! for Java project builds and Android development
Build Tools Quest #8 Intermediate

Gradle

Install Gradle build tool using SDKMAN! for Java project builds and Android development

gradlebuild-toolsjavaandroid
Download as:

What is Gradle?

Gradle Build Tool is a build automation tool for multi-language software development. It controls the development process in the tasks of compilation and packaging to testing, deployment, and publishing.

Supported languages include Java, C++, and JavaScript. While not strictly required for running automated tests (unless your tests are written with Gradle), it could be required for building an APK file from a project for testing specific features/changes.

Prerequisites

Installation

Install the latest version:

sdk install gradle

Install a specific version:

sdk install gradle <version>

Close your terminal session.

Verify Your Installation

Open a new terminal session:

gradle -v

You should see output similar to:

------------------------------------------------------------
Gradle <gradle-version>
------------------------------------------------------------

Build time:   <build-timestamp>
Revision:     <revision-hash>

Kotlin:       <kotlin-version>
Groovy:       <groovy-version>
Ant:          <ant-version>
JVM:          <jvm-version>
OS:           <os-info>

Switch Versions

Set global version:

sdk default gradle <version>

Use version in current shell only:

sdk use gradle <version>

List available versions:

sdk list gradle

For more details on SDK version management, refer to the SDKMAN! foundation guide.

Troubleshooting

”gradle: command not found”

  1. Verify SDKMAN! is initialized:

    sdk version
  2. Check Gradle is installed:

    sdk current gradle
  3. Re-source your shell:

    # For Zsh users
    source ~/.zshrc
    
    # For Bash users
    source ~/.bashrc

Gradle Version Mismatch with Project

If a project requires a specific Gradle version:

# Install the required version
sdk install gradle <version>

# Use it for this session
sdk use gradle <version>

Or use the Gradle Wrapper (./gradlew) which manages versions automatically.

Build Failures with Java Version

Gradle versions have specific Java compatibility requirements:

GradleMin JavaMax Java
8.x824
7.x819
6.x815

Check your Java version and switch if needed:

sdk current java
sdk use java <compatible-version>

Slow Builds

Enable Gradle daemon and caching in ~/.gradle/gradle.properties:

org.gradle.daemon=true
org.gradle.caching=true
org.gradle.parallel=true

Resources

πŸ”—
Gradle Build Tool gradle.org

Official Gradle website with documentation and tutorials

πŸ”—
SDKMAN! Usage Documentation sdkman.io

Learn how to manage Gradle versions with SDKMAN!