gradlePath
Path to the Gradle used for building Android applications.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Property
- Namespace: UnityEditor.Android
- Assembly: UnityEditor.Android.Extensions
public static string gradlePath { get; set; }
Remarks
- If you provide an empty string or a null, Unity enables the Installed with Unity (recommended) option in the Android section of the External Tools window.
- If you provide a valid, non-empty path, Unity disables the Installed with Unity (recommended) option and uses the Gradle at the specified path.
- If you provide an invalid, non-empty path, Unity throw an exception.
Examples
using UnityEngine;using UnityEditor;using UnityEditor.Android;public class GradlePathSample{ [MenuItem("Build/Set Custom Gradle Path")] public static void SetGradlePath() { // Set a custom path for the Gradle installation string customGradlePath = "/path/to/your/gradle"; AndroidExternalToolsSettings.gradlePath = customGradlePath; Debug.Log($"Gradle Path set to: {AndroidExternalToolsSettings.gradlePath}"); } [MenuItem("Build/Reset Gradle Path To Default")] public static void ResetGradlePath() { // Reset Gradle path to Unity's default AndroidExternalToolsSettings.gradlePath = string.Empty; Debug.Log("Gradle Path reset to 'Installed with Unity (recommended)'."); } [MenuItem("Build/Get Current Gradle Path")] public static void GetGradlePath() { // Retrieve the currently configured Gradle path string currentGradlePath = AndroidExternalToolsSettings.gradlePath; Debug.Log($"Current Gradle Path: {currentGradlePath}"); }}