245

How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path. enter image description here

Zoe
  • 27,060
  • 21
  • 118
  • 148
Deniz
  • 12,332
  • 10
  • 44
  • 62
  • [Gradle location is incorrect error while importing ActionBarsherlock in Android Studio](https://stackoverflow.com/q/17623439/6521116) – LF00 Jul 11 '17 at 04:20

30 Answers30

241

The gradle plugin (which contains a bundled version of gradle) should be already installed in where/you/installed/android-studio/plugins/gradle so you shouldn't need to manually download it. Depending on the version of Android Studio, that last directory may be where/you/installed/android-studio/gradle/gradle-x.y.z (x.y.z is the version, so check your filesystem for the exact path).

If you intend on doing gradle development outside Android Studio or want a different version, you can download it separately and point it at that path, but if you only want to get Android Studio working with the bundled version, this path should do it.

byteit101
  • 3,910
  • 2
  • 20
  • 29
  • 17
    The path plugins/gradle is to the gradle plugin, not gradle. – vharron May 03 '14 at 03:22
  • Is there any differences between them for the purposes of importing projects in Android Studio? – byteit101 May 03 '14 at 03:27
  • 44
    I think it'd be better to use a real gradle dir. It's wherever you installed it plus "libexec" for me, e.g. `/usr/local/opt/gradle/` (from Homebrew on Mac) – AlexChaffee May 20 '14 at 18:32
  • 2
    I just tried this with Android Studio 0.8.0 and it complained about using the plugin directory. I noticed though that gradle seems to be entirely located within the lib subdir, so I then instead pointed Android Studio to where/you/installed/android-studio/plugins/gradle/lib and it worked. – Tyrel Aug 22 '14 at 03:02
  • 2
    Do not point it to the gradle-plugin but to the gradle-library which is in `.../android-studio/plugins/gradle/**lib**` – hotzen Sep 28 '14 at 14:19
  • 3
    If you point to the gradle-lib as last person commented you will get an error from Android Studio that is not the right folder. – lagos Sep 30 '14 at 07:56
  • 9
    the directory in this answer was different for me. I used /install/path/to/android-studio/gradle/gradle-2.2.1 – OKGimmeMoney Jan 03 '15 at 00:17
  • @AlexChaffee Could you share the whole path entry you have there. I'm also on OS X + Homebrew. What do you mean by 'plus "libexec"', precisely? IntelliJ IDEA 14.0.3, gradle 2.3 – akauppi Feb 17 '15 at 18:36
  • 4
    OS X + Homebrew: /usr/local/Cellar/gradle/2.3/libexec/ – akauppi Feb 17 '15 at 18:49
  • Mine was here: C:\Program Files\Android\Android Studio\gradle\gradle-3.2 – jim Jan 07 '18 at 00:16
105

For Mac OS, you can use the following -

  1. /usr/local/opt/gradle/libexec/ or more generically - path/to/gradle/libexec/ - this is recommended. (the first path is what's achieved after installing gradle via Homebrew)
  2. /path/to/android/studio/plugins/gradle - I don't recommend this because this version of Gradle might be out of date, and Android Studio itself might say it's incompatible.
Abhinav Manchanda
  • 6,546
  • 3
  • 39
  • 46
  • 4
    Thanks, /usr/local/Cellar/gradle/2.3/libexec/ worked for me. + you might add that your reply has to do with OS X + Homebrew. – akauppi Feb 17 '15 at 18:41
  • say me: "graddle libexe is not supported, would you like to use graddle wrapper to update automatically ?" i clicked "yes" and alles was ok, it was strange because ; "brew info gradle " give this folder "/usr/local/Cellar/gradle/3.1" but Android Studio does not recognise gradle there – stackdave Jul 03 '17 at 09:41
47

You should be able to find it in C:\Program Files\Android\Android Studio\Gradle\Gradle 2.2.1. This is running Windows 7 64-Bit. Android Studio 1.0.2.

Taifun
  • 6,165
  • 17
  • 60
  • 188
Megaman
  • 471
  • 4
  • 2
38

OSX (Less han two minutes)

  1. Open terminal
  2. Check if Gradle installed gradle --version, if so, goto step 4
  3. If not brew install gradle and Goto step 2
  4. Copy /usr/local/opt/gradle/libexec/
  5. Paste it in Import Project Window in Android Studio > Gradle Home
  6. Important, Celebrate!
josuebasurto
  • 591
  • 4
  • 7
26
  1. Download Gradle http://www.gradle.org/downloads
  2. Install
  3. Set Gradle home to the install directory
user3118604
  • 854
  • 6
  • 12
21

On Linux run: whereis gradle.

For me it was /usr/lib/gradle/1.10.

Andrew Tobilko
  • 48,120
  • 14
  • 91
  • 142
insomniac
  • 379
  • 5
  • 7
  • A better option will be to use /usr/lib/gradle/default no to depend on specific version – Calin Aug 27 '14 at 11:24
13

I ran into same problem. I selected location C:\Program Files (x86)\Android\android-studio\plugins\gradle as Gradle Home

Khayam Gondal
  • 2,366
  • 2
  • 28
  • 40
11

In Ubuntu 14.04 after $ sudo apt-get install gradle I've got

$ whereis gradle
gradle: /usr/bin/gradle /usr/bin/X11/gradle /usr/share/gradle /usr/share/man/man1/gradle.1.gz

The path to Gradle was /usr/share/gradle

kza
  • 1,590
  • 13
  • 32
8

For Mac,

/Applications/Android Studio.app/Contents/gradle/gradle-3.2
LF00
  • 27,015
  • 29
  • 156
  • 295
4

Download Gradle as described above, but make sure you download version 1.9 and not the current release (1.11). I just had the same problem and downloaded the current release only to have Android Studio tell me it wasn't supported.

  • Gradle plugin 0.9.0 and 0.10.0 both support Android Studio http://tools.android.com/tech-docs/new-build-system – vharron May 03 '14 at 03:40
4

On Arch Linux I could not find it, so I added:

echo $APP_HOME

to /usr/bin/grade (found over which gradle)

The Install dir for me was /usr/share/java/gradle/

mnzl
  • 372
  • 3
  • 14
3

For migrating from eclipse to android studio

(Do not need to specify the Gradle home.)

  1. Locate the project you exported from Eclipse, expand it, select the build.gradle file and click OK.
  2. In the following dialog, leave Use gradle wrapper selected and click OK.

Try this for windows users

http://blog.blundell-apps.com/setting-up-android-studio-gradle-windows-7/

Deniz
  • 12,332
  • 10
  • 44
  • 62
3

I tried byteit101's solution but whether I chose android-studio-path/plugins/gradle or android-studio-path/plugins/gradle/lib the IDE said it isn't correct.

Then I changed the gradle home to android-studio-path/gradle/gradle-x.x.x and it works.

Community
  • 1
  • 1
Yen NQ
  • 749
  • 7
  • 12
3

Mac OSX / Linux

Step 1: Open terminal :)
Step 2: Open .bash_profile in vim to edit: 
        > vi ~/.bash_profile 
Step 3: Add line: 
        > export GRADLE_HOME=/usr/local/opt/gradle 
        (for me it was this location, it can be different for u)
Step 4: Add line: 
        > export PATH="$PATH:$GRADLE_HOME/bin" 
        (to export bin directory of gradle)
Step 5: Verify by reopening the terminal or new tab, and check by echoing: 
        > echo $GRADLE_HOME
UserBSS1
  • 2,091
  • 1
  • 28
  • 31
2

On Linux Mint 17 it was

/usr/share/gradle

for me

Xiao
  • 1,552
  • 2
  • 22
  • 20
2

If you are on a Windows machine, go to the directory:

C:\Program Files\Android\Android Studio\gradle\

Click the gradle-4.4 folder from Android Studio\File\Settings, and then click the Apply button.

enter image description here

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
1

This is my solution on AndroidStudio/Idea for Mac

$ env | grep GRADLE
GRADLE_HOME=/usr/local/Cellar/gradle/2.6
GRADLE_USER_HOME=/Users/leon/.gradle
Miao1007
  • 944
  • 6
  • 22
1

I used umake to install android studio. For me the path was

/home/user/.local/share/umake/android/android-studio/gradle/gradle-2.14.1
liteflier
  • 327
  • 2
  • 8
1

I had to use this

"C:\Program Files\Android\Android Studio\gradle\gradle-4.1"

Change the version if you have a different one.

Kofi Sammie
  • 3,237
  • 1
  • 17
  • 17
0

Don't need to download or specify anything...

Just go to the install Android Studio plugins Path and search for any file like gradle-wrapper-x.xx.jar (x.xx = version number). Copy it to a subfolder of your project root folder named : gradle.

Example : - file found gradle-wrapper-1.12.jar in plugins folder of Android Studio Install's path - my project was on D:\android_repo\myProject - created a folder into D:\android_repo\myProject\gradle - copy gradle-wrapper-1.12.jar to this folder D:\android_repo\myProject\gradle - import again my project and no more question about gradle.

karthik manchala
  • 13,492
  • 1
  • 31
  • 55
Nabbar
  • 1
0

I am using Lubuntu, I ended up finding it in :

/usr/share/gradle

Mohamed ALOUANE
  • 5,349
  • 6
  • 29
  • 60
0

In Windows

..\AndroidStudio2.0Beta6\android-studio\gradle\gradle-2.10
ekad
  • 14,436
  • 26
  • 44
  • 46
Shaun
  • 173
  • 1
  • 6
0

I've stumble across this question, trying to build an Ionic + Cordova app using Gradle from Android Studio installation, rather that installing Gradle separately.

On Centos, the Gradle binary was here: /home/YOURUSERNAME/.gradle/wrapper/dists/gradle-VERSION-all/CUSTOM_HASH/gradle-VERSION/bin

So, I've added export PATH=/home/maxim/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin:$PATH to my ~/.bashrc and ionic cordova run android command worked just fine.

Maxim Mazurok
  • 3,856
  • 2
  • 22
  • 37
0

If you are on windows machine, go to the directory C:\Program Files\Android\Android Studio\gradle\ and click the gradle folder and apply it on

Yog
  • 817
  • 1
  • 10
  • 19
0

This worked. C:\Program Files\Android\Android Studio\gradle\gradle-3.2

jim
  • 228
  • 4
  • 10
0

If you're using MacPorts gradle's home is:

/opt/local/share/java/gradle
freedev
  • 25,946
  • 8
  • 108
  • 125
0

For Ubuntu default version is /usr/lib/gradle/default. In case of update, you don't need to reassign link in idea/studio.

Yaro
  • 614
  • 6
  • 13
0

For OSX, if going to Finder, navigate to this category: /usr/local/opt/ if you do not see gradle folder, install your grandle version manually:

https://services.gradle.org/distributions/gradle-5.4.1-all.zip

https://services.gradle.org/distributions/gradle-4.4.1-all.zip

If you are looking for specific Gradle version, simply change the version number from the zip links above, unzip and add that in the Gradle folder /usr/local/opt/gradle

itzo
  • 1,220
  • 14
  • 18
0

If you are on a Windows machine, gradle home is located inside the installation folder of your Android Studio, usually at:

C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1

Change the version if you have a different one.

Henrique Monte
  • 1,272
  • 1
  • 15
  • 22
0

On Windows it was

C:/Android Studio/jre

Iman Marashi
  • 5,593
  • 38
  • 51