Mac environment variables to configure Android Studio Gradle

After you install Android Studio on a Mac, there is no default configuration environment variable, and therefore can not access the Terminal is gradle, this article is to make Android Studio can use Gradle.

1, gradle directory to find the AS where I is as follows:

/Applications/Android Studio.app/Contents/gradle/

as the picture shows:


3943649-d1a5e41141a13116.png
gradle1.png

ps: the terminal may record the copy path gradle

2, the configuration file bash_profile

Open the terminal, enter the following:
open .bash_profile
Configuring global environment variables:
export PATH=$PATH:/Applications/Android\ Studio.app/Contents/gradle/gradle-5.1.1/bin
cmd + s save the file, cut to the terminal window, to execute:
source .bash_profile
In the AS terminal input, query version gradle
gradle -v
This time will be given:
gradle: Permission denied
Back to the terminal window, enter the permissions configuration commands:
chmod +x /Applications/Android\ Studio.app/Contents/gradle/gradle-5.1.1/bin/gradle
Finally, once again enter into force command:
source .bash_profile
At this time window then the input terminal AS gradle -vqueries the version number, i.e., successfully shown below:
3943649-d463b97b3e05178a.png
gradle2.png
At this point, you can happily use gradle related commands in Android Studio in ~

Guess you like

Origin blog.csdn.net/weixin_33692284/article/details/90981160