如何在Android studio中导入已有项目的同时设置gradle home

时间:2023-01-27 10:11:26

How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path. 如何在Android studio中导入已有项目的同时设置gradle home

如何在Android studio中导入现有项目的同时设置gradle home。在尝试导入时,我需要设置此路径。

25 个解决方案

#1


213  

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).

gradle插件(包含了gradle的捆绑版本)应该已经安装在你/安装/android-studio/plugins/gradle中,所以你不需要手动下载。根据Android Studio的版本,最后的目录可能是/you/installed/ Android - Studio /gradle/gradle-x.y。z(x.y。z是版本,所以请检查您的文件系统以找到正确的路径)。

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.

如果您打算在Android Studio之外进行gradle开发,或者想要一个不同的版本,您可以单独下载并将其指向那个路径,但是如果您只想让Android Studio使用捆绑版,那么这条路径应该可以做到。

#2


85  

For Mac OS, you can use the following -

对于Mac OS,您可以使用以下命令。

  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. /usr/local/opt/gradle/libexec/或更通用的路径/to/gradle/libexec/ -这是推荐的。(第一个路径是通过Homebrew安装gradle后实现的)
  3. /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.
  4. /path/to/android/studio/plugins/gradle——我不推荐这个版本,因为这个版本的gradle可能已经过时了,android studio本身可能会说它不兼容。

#3


40  

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.

你应该能够找到它在C:\Program Files\Android\Android Studio \ Gradle \ Gradle 2.2.1。这是在运行64位的Windows 7。Android 1.0.2工作室。

#4


24  

  1. Download Gradle http://www.gradle.org/downloads
  2. 下载Gradle http://www.gradle.org/downloads
  3. Install
  4. 安装
  5. Set Gradle home to the install directory
  6. 将Gradle home设置为安装目录

#5


18  

On Linux run: whereis gradle.

在Linux上运行:什么是gradle。

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

对我来说,它是/usr/lib/gradle/1.10。

#6


18  

OSX (Less han two minutes)

OSX(少汉2分钟)

  1. Open terminal
  2. 打开终端
  3. Check if Gradle installed gradle --version, if so, goto step 4
  4. 检查是否安装了第等级—版本,如果安装了版本,则执行步骤4
  5. If not brew install gradle and Goto step 2
  6. 如果没有酿造,安装等级和去步骤2
  7. Copy /usr/local/opt/gradle/libexec/
  8. 复制/usr/local/opt/gradle/libexec/
  9. Paste it in Import Project Window in Android Studio > Gradle Home
  10. 将其粘贴到Android Studio > Gradle Home的导入项目窗口中。
  11. Important, Celebrate!
  12. 重要的是,好好庆祝一下吧!

#7


10  

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

在ubuntu14.04 $ sudo apt-get安装后,我有一个等级

$ 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

等级的路径是/usr/share/gradle

#8


10  

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

我遇到了同样的问题。我选择位置C:\Program Files (x86)\Android\ android-studio \ plugins \ gradle gradle回家

#9


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.

下载第1.9版,而不是当前版本(1.11)。我只是遇到了同样的问题,下载了当前版本,结果Android Studio告诉我它不支持。

#10


4  

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

在Arch Linux上我找不到它,所以我补充说:

echo $APP_HOME

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

to /usr/bin/grade(在哪个级别上找到)

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

我的安装目录是/usr/share/java/gradle/

#11


4  

For Mac,

对于Mac,

/Applications/Android Studio.app/Contents/gradle/gradle-3.2

#12


3  

For migrating from eclipse to android studio

从eclipse迁移到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. 定位从Eclipse导出的项目,展开它,选择构建。渐变文件,点击确定。
  3. In the following dialog, leave Use gradle wrapper selected and click OK.
  4. 在下面的对话框中,请选择使用gradle包装器并单击OK。

Try this for windows users

对windows用户试试这个

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

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

#13


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.

我尝试了byteit101的解决方案,但是无论我选择android-studio-path/plugins/gradle还是android-studio-path/plugins/gradle/lib, IDE都说这是错误的。

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

然后我把gradle home改为android-studio-path/gradle/gradle-x.x。x和它的工作原理。

#14


2  

On Linux Mint 17 it was

在Linux Mint 17上。

/usr/share/gradle

for me

对我来说

#15


2  

Mac OSX / Linux

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

#16


1  

This is my solution on AndroidStudio/Idea for Mac

这是我为Mac设计的AndroidStudio/Idea的解决方案。

$ env | grep GRADLE
GRADLE_HOME=/usr/local/Cellar/gradle/2.6
GRADLE_USER_HOME=/Users/leon/.gradle

#17


1  

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

我用umake安装android studio。对我来说,这条路是。

/home/user/.local/share/umake/android/android-studio/gradle/gradle-2.14.1

#18


0  

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

我正在使用Lubuntu,最后我在:

/usr/share/gradle

/usr/share/gradle

#19


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.

只需进入安装Android Studio插件路径,搜索任何文件,如gradle wrapper-x.xx。jar(x。xx =版本号)。将它复制到名为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.

例子:-文件发现了每1 -1.12级。我的项目在D:\android_repo\myProject上,我把一个文件夹创建为D:\android_repo\myProject\gradle - copy gradle-wrapper-1.12。jar到这个文件夹D:\android_repo\myProject\gradle -再次导入我的项目,不再有关于gradle的问题。

#20


0  

In Windows

在Windows中

..\AndroidStudio2.0Beta6\android-studio\gradle\gradle-2.10

#21


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.

我无意中发现了这个问题,我试图使用Android Studio安装的Gradle构建一个Ionic + Cordova应用,而不是分别安装Gradle。

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

在Centos,第二级二进制文件在这里:/home/ yourusername /.gradle/包装器/dists/ Gradle - version -all/CUSTOM_HASH/ grade - 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.

因此,我添加了export PATH=/home/maxim/.gradle/wrapper/dists/gradle-4.1-all/ bzyivzo639fup2jbap0tjew /bin:$PATH to my ~/。bashrc和ionic cordova运行android命令运行正常。

#22


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

如果你在windows机器上,去C:\Program Files\Android\Android Studio \ gradle \目录并单击gradle文件夹和应用

#23


0  

I had to use this

我必须用这个

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

“C:\ Program Files \ \ Android工作室\ gradle \ gradle - 4.1”

Change the version if you have a different one.

如果您有不同的版本,请更改版本。

#24


0  

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

这工作。C:\Program Files\Android\Android Studio \ gradle \ gradle - 3.2

#25


0  

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

如果您在Windows机器上,请转到以下目录:

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

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

点击Android Studio\File\Settings中的gradle-4.4文件夹,然后点击Apply按钮。

如何在Android studio中导入已有项目的同时设置gradle home

#1


213  

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).

gradle插件(包含了gradle的捆绑版本)应该已经安装在你/安装/android-studio/plugins/gradle中,所以你不需要手动下载。根据Android Studio的版本,最后的目录可能是/you/installed/ Android - Studio /gradle/gradle-x.y。z(x.y。z是版本,所以请检查您的文件系统以找到正确的路径)。

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.

如果您打算在Android Studio之外进行gradle开发,或者想要一个不同的版本,您可以单独下载并将其指向那个路径,但是如果您只想让Android Studio使用捆绑版,那么这条路径应该可以做到。

#2


85  

For Mac OS, you can use the following -

对于Mac OS,您可以使用以下命令。

  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. /usr/local/opt/gradle/libexec/或更通用的路径/to/gradle/libexec/ -这是推荐的。(第一个路径是通过Homebrew安装gradle后实现的)
  3. /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.
  4. /path/to/android/studio/plugins/gradle——我不推荐这个版本,因为这个版本的gradle可能已经过时了,android studio本身可能会说它不兼容。

#3


40  

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.

你应该能够找到它在C:\Program Files\Android\Android Studio \ Gradle \ Gradle 2.2.1。这是在运行64位的Windows 7。Android 1.0.2工作室。

#4


24  

  1. Download Gradle http://www.gradle.org/downloads
  2. 下载Gradle http://www.gradle.org/downloads
  3. Install
  4. 安装
  5. Set Gradle home to the install directory
  6. 将Gradle home设置为安装目录

#5


18  

On Linux run: whereis gradle.

在Linux上运行:什么是gradle。

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

对我来说,它是/usr/lib/gradle/1.10。

#6


18  

OSX (Less han two minutes)

OSX(少汉2分钟)

  1. Open terminal
  2. 打开终端
  3. Check if Gradle installed gradle --version, if so, goto step 4
  4. 检查是否安装了第等级—版本,如果安装了版本,则执行步骤4
  5. If not brew install gradle and Goto step 2
  6. 如果没有酿造,安装等级和去步骤2
  7. Copy /usr/local/opt/gradle/libexec/
  8. 复制/usr/local/opt/gradle/libexec/
  9. Paste it in Import Project Window in Android Studio > Gradle Home
  10. 将其粘贴到Android Studio > Gradle Home的导入项目窗口中。
  11. Important, Celebrate!
  12. 重要的是,好好庆祝一下吧!

#7


10  

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

在ubuntu14.04 $ sudo apt-get安装后,我有一个等级

$ 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

等级的路径是/usr/share/gradle

#8


10  

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

我遇到了同样的问题。我选择位置C:\Program Files (x86)\Android\ android-studio \ plugins \ gradle gradle回家

#9


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.

下载第1.9版,而不是当前版本(1.11)。我只是遇到了同样的问题,下载了当前版本,结果Android Studio告诉我它不支持。

#10


4  

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

在Arch Linux上我找不到它,所以我补充说:

echo $APP_HOME

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

to /usr/bin/grade(在哪个级别上找到)

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

我的安装目录是/usr/share/java/gradle/

#11


4  

For Mac,

对于Mac,

/Applications/Android Studio.app/Contents/gradle/gradle-3.2

#12


3  

For migrating from eclipse to android studio

从eclipse迁移到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. 定位从Eclipse导出的项目,展开它,选择构建。渐变文件,点击确定。
  3. In the following dialog, leave Use gradle wrapper selected and click OK.
  4. 在下面的对话框中,请选择使用gradle包装器并单击OK。

Try this for windows users

对windows用户试试这个

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

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

#13


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.

我尝试了byteit101的解决方案,但是无论我选择android-studio-path/plugins/gradle还是android-studio-path/plugins/gradle/lib, IDE都说这是错误的。

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

然后我把gradle home改为android-studio-path/gradle/gradle-x.x。x和它的工作原理。

#14


2  

On Linux Mint 17 it was

在Linux Mint 17上。

/usr/share/gradle

for me

对我来说

#15


2  

Mac OSX / Linux

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

#16


1  

This is my solution on AndroidStudio/Idea for Mac

这是我为Mac设计的AndroidStudio/Idea的解决方案。

$ env | grep GRADLE
GRADLE_HOME=/usr/local/Cellar/gradle/2.6
GRADLE_USER_HOME=/Users/leon/.gradle

#17


1  

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

我用umake安装android studio。对我来说,这条路是。

/home/user/.local/share/umake/android/android-studio/gradle/gradle-2.14.1

#18


0  

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

我正在使用Lubuntu,最后我在:

/usr/share/gradle

/usr/share/gradle

#19


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.

只需进入安装Android Studio插件路径,搜索任何文件,如gradle wrapper-x.xx。jar(x。xx =版本号)。将它复制到名为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.

例子:-文件发现了每1 -1.12级。我的项目在D:\android_repo\myProject上,我把一个文件夹创建为D:\android_repo\myProject\gradle - copy gradle-wrapper-1.12。jar到这个文件夹D:\android_repo\myProject\gradle -再次导入我的项目,不再有关于gradle的问题。

#20


0  

In Windows

在Windows中

..\AndroidStudio2.0Beta6\android-studio\gradle\gradle-2.10

#21


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.

我无意中发现了这个问题,我试图使用Android Studio安装的Gradle构建一个Ionic + Cordova应用,而不是分别安装Gradle。

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

在Centos,第二级二进制文件在这里:/home/ yourusername /.gradle/包装器/dists/ Gradle - version -all/CUSTOM_HASH/ grade - 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.

因此,我添加了export PATH=/home/maxim/.gradle/wrapper/dists/gradle-4.1-all/ bzyivzo639fup2jbap0tjew /bin:$PATH to my ~/。bashrc和ionic cordova运行android命令运行正常。

#22


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

如果你在windows机器上,去C:\Program Files\Android\Android Studio \ gradle \目录并单击gradle文件夹和应用

#23


0  

I had to use this

我必须用这个

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

“C:\ Program Files \ \ Android工作室\ gradle \ gradle - 4.1”

Change the version if you have a different one.

如果您有不同的版本,请更改版本。

#24


0  

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

这工作。C:\Program Files\Android\Android Studio \ gradle \ gradle - 3.2

#25


0  

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

如果您在Windows机器上,请转到以下目录:

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

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

点击Android Studio\File\Settings中的gradle-4.4文件夹,然后点击Apply按钮。

如何在Android studio中导入已有项目的同时设置gradle home