4

I have a Macbook with Android Studio installed. Since I have projects that use Gradle (and Android Studio also uses Gradle), I would assume I have Gradle installed on my machine somewhere. However if I type gradle into the terminal I get command not found. So, do I have Gradle automatically installed because I have Android Studio, or do I have to run brew install gradle ?

I know this is a bad/silly question, but I just want to make sure I don't install Gradle twice.

hippietrail
  • 14,735
  • 16
  • 96
  • 147
lijas
  • 417
  • 1
  • 6
  • 16
  • Well-behaved projects use the gradle wrapper. So you don't need to install gradle: the gradle wrapper downloads and uses it for you. https://docs.gradle.org/4.0/userguide/gradle_wrapper.html – JB Nizet Nov 05 '17 at 11:04

2 Answers2

5

You shouldn't need to install Gradle at all. The projects are likely using the Gradle wrapper - i.e. you should just be able to run ./gradlew whatever inside their root directories.

In the unlikely case that they're not using the wrapper, then brew install gradle ought to work on a Mac.

(I don't know anything about whether Android Studio deploys Gradle, but if it does, clearly it does so in a way that doesn't play well with your PATH.)

Oliver Charlesworth
  • 260,367
  • 30
  • 546
  • 667
  • If I type `./gradlew` in the terminal at my root directory, i get `Permission denied`. How can I fix this? Edit: I solved it by cmod-ing it. Thanks for the help! – lijas Nov 05 '17 at 11:15
  • According to a warning I just got using [Ghidra](https://ghidra-sre.org/), Gradle wrapper requires an internet connection. So if there are ever times when you might need to use Gradle without internet access, then that might be a case for installing it. – hippietrail May 28 '20 at 05:15
1

The correct answer can be found here: Gradle home cannot be found on Mac.

Command: brew info gradle

As the result you will have something like this:

gradle: stable 4.0.1
Build system based on the Groovy language
https://www.gradle.org/
/usr/local/Cellar/gradle/3.4 (181 files, 74.5MB) *
Built from source on 2017-02-24 at 15:01:34
From: https://github.com/Homebrew/homebrew-        core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.7 ✔
==> Options
--with-all
Installs Javadoc, examples, and source in addition to the binaries

Here, on the line 4 you can see the home path: /usr/local/Cellar/gradle/3.4

Adam Hurwitz
  • 8,325
  • 6
  • 64
  • 117