Gradle的安装

本教程主要参照官方说明文档
https://docs.gradle.org/current/userguide/userguide.html
在安装Gradle之前首先要确保java JDK已经安装好了,所以首先需要安装jdk。

一、安装java JDK
1、下载jdk

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

2、解压文件,修改文件名

$ sudo mkdir /usr/lib/jvm
$ sudo tar zxvf jdk-7u21-linux-i586.tar.gz -C /usr/lib/jvm
$ cd /usr/lib/jvm
$ sudo mv jdk1.7.0_21 java

3、添加环境变量
$ sudo vim ~/.bashrc

加入如下内容

export JAVA_HOME=/usr/lib/jvm/java 
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH  

4、配置默认JDK版本

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/bin/java 300  
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/bin/javac 300  
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java/bin/jar 300   
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/bin/javah 300   
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java/bin/javap 300 

然后执行

sudo update-alternatives --config java

5、测试

$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Server VM (build 23.21-b01, mixed mode)

二、安装Gradle
1、下载gradle
http://gradle.org/gradle-download/

2、解压下载的gradle,修改环境变量
解压gradle

$ sudo mkdir /usr/lib/gradle
$ sudo unzip gradle-2.7-all.zip /usr/lib/gradle

修改环境变量

$ sudo vim ~/.bashrc

加入如下内容

export GRADLE=/usr/lib/gradle/gradle-2.7
export PATH=${GRADLE}/bin:$PATH 

执行

source ~/.bashrc

3、测试

gradle -v ------------------------------------------------------------
Gradle 2.7 ------------------------------------------------------------

Build time:   2015-09-14 07:26:16 UTC
Build number: none
Revision:     c41505168da69fb0650f4e31c9e01b50ffc97893

你可能感兴趣的:(android,安装,gradle)