1. 程式人生 > >Android Studio之bash: gradlew: command not found

Android Studio之bash: gradlew: command not found

在Mac OSX中,Android Studio執行編譯命令報錯:bash: gradlew: command not found

引起原因:gradlew不在系統全域性變數路徑中,當執行命令時會報錯,提示找不到。

解決方法1:使用 ./指定當前目錄,如: 

./gradlew :upay_plugi:build

解決方法2:配置全域性環境變數

   a)找到gradle檔案所在路徑。該檔案可在Android Studio安裝目錄下找到,如:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/bin

   b)配置.bash_profile檔案。如:

  1. export PATH=${PATH}:/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin    
注意AndroidStudio單詞間的 \ + 空格。

   c)使.bash_profile檔案立刻生效。在終端執行:source .bash_profile