Rahul R
Rahul R

Reputation: 141

I have Android Studio installed, but I am unable to access gradle through command line

I have Android Studio installed, but I am unable to access gradle through command line.

gradle --version
gradle: command not found

Do I have to install it separately in if I want to use gradle for java projects or am I missing it because I haven't added to the path etc?

Upvotes: 4

Views: 4077

Answers (2)

Martin Braun
Martin Braun

Reputation: 12619

If all you want to do is run an existing Gradle build, then you don’t need to install Gradle if the build has a Gradle Wrapper, identifiable via the gradlew and/or gradlew.bat files in the root of the build. You just need to make sure your system satisfies Gradle’s prerequisites.

Android Studio comes with a working installation of Gradle, so you don’t need to install Gradle separately in that case.

In order to create a new build or add a Wrapper to an existing build, you will need to install Gradle according to these instructions.

from https://docs.gradle.org/current/userguide/getting_started.html#gs:installation

Since I want to use gradle globally to make a Java library (not Android) I ended up installing a separate copy of gradle using SDKMAN! since I use SDKMAN! to manage multiple Java versions on my system already:

sdk install gradle

Although, gradle should be available on many other package managers as well.

Upvotes: 1

Prateek Jain
Prateek Jain

Reputation: 1552

It's because gradle is not installed globally or not in your PATH environment variable.

You can use gradle wrapper which is located at the project root. Move to project dir and run ./gradlew --version

Upvotes: 3

Related Questions