安裝: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.
出現(xiàn)這個(gè)錯(cuò)誤的時(shí)候是因?yàn)檎也坏綄?duì)應(yīng)的jdk
sudo gedit /usr/bin/gradle
#export JAVA_HOME=/usr/lib/jvm/default-java
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
出現(xiàn)這個(gè)錯(cuò)誤Could not find method jcenter() for arguments [] on repository container.
是因?yàn)閡buntu倉(cāng)庫(kù)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
環(huán)境變量生效source /etc/profile
gradle -v