Gradle
Install Gradle build tool using SDKMAN! for Java project builds and Android development
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β
-
Verify SDKMAN! is initialized:
sdk version -
Check Gradle is installed:
sdk current gradle -
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:
| Gradle | Min Java | Max Java |
|---|---|---|
| 8.x | 8 | 24 |
| 7.x | 8 | 19 |
| 6.x | 8 | 15 |
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
Official Gradle website with documentation and tutorials
Learn how to manage Gradle versions with SDKMAN!