Mac下gradle默認不是配置在全局下的,即不可在任意目錄下進行gradle命令,
如:gradle -v
但是我們為了方便,通常會將其配置在全局應用。
步驟如下:
- 打開.bash_profile,命令行輸入:
open .bash_profile - 添加gradle的path,訪達中找到Android Studio,右鍵,顯示包內容,找到bin文件夾
復制bin路徑,注意Android Studio之間有空格,需要轉移“\”,在bash_profile中添加,跟隨其他PATH后面,export path是以:分割的。
:/Applications/Android\ Studio.app/Contents/gradle/gradle-5.1.1/bin - 使更改生效,命令行輸入:
source .bash_profile - 若提示沒有權限:Permission denied,則給予超級管理員權限:
chmod +x /Applications/Android\ Studio.app/Contents/gradle/gradle-5.1.1/bin/gradle - 驗證是否配置成功:
gradle -v
大功告成!!!
