[英]How to set gradle home while importing existing project in Android studio
How to set gradle home while importing existing project in Android studio.如何在 Android 工作室中导入现有项目时设置 gradle 主页。 While trying to import I need to set up this path.
在尝试导入时,我需要设置此路径。
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. gradle插件(包含捆绑版本的gradle)应该已经安装在/ you / installed / android-studio / plugins / gradle中,所以你不需要手动下载它。 Depending on the version of Android Studio, that last directory may be where/you/installed/android-studio /gradle/gradle-xyz (xyz is the version, so check your filesystem for the exact path).
根据Android Studio的版本,最后一个目录可能是/ you / installed / android-studio / gradle / gradle-xyz(xyz是版本,因此请检查文件系统中的确切路径)。
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使用捆绑版本,则此路径应该执行此操作。
For Mac OS, you can use the following - 对于Mac OS,您可以使用以下 -
/usr/local/opt/gradle/libexec/
or more generically - path/to/gradle/libexec/
- this is recommended. /usr/local/opt/gradle/libexec/
或更一般 - path/to/gradle/libexec/
- 这是推荐的。 (the first path is what's achieved after installing gradle via Homebrew) /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. /path/to/android/studio/plugins/gradle
- 我不推荐这个,因为这个版本的Gradle可能已经过时了,Android Studio本身可能会说它不兼容。 You should be able to find it in C:\\Program Files\\Android\\Android Studio\\Gradle\\Gradle 2.2.1
. 您应该能够在
C:\\Program Files\\Android\\Android Studio\\Gradle\\Gradle 2.2.1
找到它。 This is running Windows 7 64-Bit. 这是运行Windows 7 64位。 Android Studio 1.0.2.
Android Studio 1.0.2。
OSX (Less han two minutes) OSX(少两分钟)
gradle --version
, if so, goto step 4 gradle --version
, 如果是,请转到步骤4 brew install gradle
and Goto step 2 brew install gradle
并转到步骤2 /usr/local/opt/gradle/libexec/
/usr/local/opt/gradle/libexec/
On Linux run: whereis gradle
. 在Linux上运行:
whereis gradle
。
For me it was /usr/lib/gradle/1.10
. 对我来说是
/usr/lib/gradle/1.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 Home
In Ubuntu 14.04 after $ sudo apt-get install gradle
I've got 在
$ sudo apt-get install gradle
之后的Ubuntu 14.04中我得到了
$ 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
Gradle的路径是
/usr/share/gradle
对于Mac,
/Applications/Android Studio.app/Contents/gradle/gradle-3.2
Download Gradle as described above, but make sure you download version 1.9 and not the current release (1.11). 如上所述下载Gradle,但请确保下载1.9版而不是当前版本(1.11)。 I just had the same problem and downloaded the current release only to have Android Studio tell me it wasn't supported.
我只是遇到了同样的问题并且下载了当前版本,只是让Android Studio告诉我它不受支持。
On Arch Linux I could not find it, so I added: 在Arch Linux上我找不到它,所以我补充道:
echo $APP_HOME
to /usr/bin/grade (found over which gradle
) 到/ usr / bin / grade(找到
which gradle
)
The Install dir for me was /usr/share/java/gradle/ 我的安装目录是/ usr / share / java / gradle /
For migrating from eclipse to android studio 用于从eclipse迁移到android studio
(Do not need to specify the Gradle home.) (不需要指定Gradle home。)
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/
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-xxx
and it works. 然后我将gradle home更改为
android-studio-path/gradle/gradle-xxx
并且它可以工作。
On Linux Mint 17 it was 在Linux Mint 17上它是
/usr/share/gradle
for me 为了我
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
This is my solution on AndroidStudio/Idea for Mac 这是我在AndroidStudio / Idea for Mac上的解决方案
$ env | grep GRADLE
GRADLE_HOME=/usr/local/Cellar/gradle/2.6
GRADLE_USER_HOME=/Users/leon/.gradle
I used umake to install android studio. 我用umake来安装android studio。 For me the path was
对我来说,路径是
/home/user/.local/share/umake/android/android-studio/gradle/gradle-2.14.1
If you are on a Windows machine, gradle home is located inside the installation folder of your Android Studio, usually at: 如果您使用的是Windows计算机,则gradle home位于Android Studio的安装文件夹中,通常位于:
C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1
Change the version if you have a different one. 如果您有不同版本,请更改版本。
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). 只需转到安装Android Studio插件路径并搜索任何文件,如gradle-wrapper-x.xx.jar(x.xx =版本号)。 Copy it to a subfolder of your project root folder named : gradle.
将其复制到名为: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. 示例: - 文件在Android Studio Install的路径的plugins文件夹中找到了gradle-wrapper-1.12.jar - 我的项目在D:\\ android_repo \\ myProject上 - 在D:\\ android_repo \\ myProject \\ gradle中创建了一个文件夹 - copy gradle-wrapper- 1.12.jar到这个文件夹D:\\ android_repo \\ myProject \\ gradle - 再次导入我的项目,没有关于gradle的更多问题。
I am using Lubuntu, I ended up finding it in : 我正在使用Lubuntu,我最终找到了:
/usr/share/gradle
的/ usr /共享/ gradle这个
在Windows中
..\AndroidStudio2.0Beta6\android-studio\gradle\gradle-2.10
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上,Gradle二进制文件在这里:
/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. 所以,我添加了
export PATH=/home/maxim/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin:$PATH
到我的~/.bashrc
和ionic cordova run android
命令工作正好。
如果您使用的是Windows计算机,请转到目录C:\\ Program Files \\ Android \\ Android Studio \\ gradle \\并单击gradle文件夹并将其应用于
I had to use this 我不得不用这个
"C:\\Program Files\\Android\\Android Studio\\gradle\\gradle-4.1"
“C:\\ Program Files \\ Android \\ Android Studio \\ gradle \\ gradle-4.1”
Change the version if you have a different one. 如果您有不同版本,请更改版本。
This worked. 这很有效。 C:\\Program Files\\Android\\Android Studio\\gradle\\gradle-3.2
C:\\ Program Files \\ Android \\ Android Studio \\ gradle \\ gradle-3.2
如果您正在使用MacPorts gradle的主页是:
/opt/local/share/java/gradle
For Ubuntu default version is /usr/lib/gradle/default
. 对于Ubuntu,默认版本是
/usr/lib/gradle/default
。 In case of update, you don't need to reassign link in idea/studio. 如果更新,您无需在idea / studio中重新分配链接。
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: 对于OSX,如果要访问Finder,请导航到以下类别: / usr / local / opt /如果您没有看到gradle文件夹,请手动安装您的grandle版本:
https://services.gradle.org/distributions/gradle-5.4.1-all.zip https://services.gradle.org/distributions/gradle-5.4.1-all.zip
https://services.gradle.org/distributions/gradle-4.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 如果您正在寻找特定的Gradle版本,只需从上面的zip链接更改版本号,解压缩并将其添加到Gradle文件夹/ usr / local / opt / gradle中
On Windows it was在 Windows 它是
C:/Android Studio/jre
C:/安卓工作室/jre
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.