安装:sudo apt-get install gradle
gradle -v
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
出现这个错误的时候是因为找不到对应的jdk
sudo gedit /usr/bin/gradle
#export JAVA_HOME=/usr/lib/jvm/default-java
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
出现这个错误Could not find method jcenter() for arguments [] on repository container.
是因为ubuntu仓库gradle版本比较旧
http://www.gradle.org/downloads
下载最新的
gradle-3.2-all.zip
解压后
sudo vim /etc/profile
exportGRADLE_HOME=/opt/gradle/gradle-3.2
export PATH=$GRADLE_HOME/bin:$PATH
环境变量生效source /etc/profile
gradle -v