1. 首先先進入Gradle官網:http://services.gradle.org/distributions/ 下載最新gradle包(根據自己需要),裏面新舊包分類清楚。
不懂下載哪個 Zip 包,請看鏈接解釋:https://jingyan.baidu.com/article/00a07f38706f0b82d028dcf3.html
2. 下載好後,在 訪達→ 應用程序,選擇 AndroidStudio.app 圖標,右鍵 選擇 "顯示包內容",進入Contents下的 gradle文件夾,將剛剛下載好的zip解壓後放入gradle文件夾內,如下:
3. AndroidStudio中,Prefences ----> Build Tools ---> Gradle,在 Gradle home中 選擇剛剛gradle的文件路徑,
/Applications/AndroidStudio.app/Contents/gradle/gradle-4.7
4. 接下來配置用戶環境變量: te 打開終端輸入 open .bash_profile
5. 在文本編輯框輸入如下:(這裏 GRADLE_HOME 要改成你剛剛在AS中配置gradle的路徑)
GRADLE_HOME=/Applications/AndroidStudio.app/Contents/gradle/gradle-4.7;
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin
6. 保存退出後,再終端輸入:source .bash_profile 更新配置。
在終端中輸入gradle -version中查看版本,如此更新成功。
adb 環境配置:
https://blog.csdn.net/testnice/article/details/78893219
https://blog.csdn.net/chaoyue0071/article/details/42192305
* 如有問題,請按照下面我給出的鏈接次序 解決問題:
(1)沒配置 .bash_profile 環境變量文件或者不會配置的看下面:
https://blog.csdn.net/maoxinwen1/article/details/80113470
(2)配置時會出現 文件或者文件夾找不到的情況:
https://blog.csdn.net/u013424496/article/details/52684213
(3) 切記 .bash_profile 中 路徑 不要寫 { }