Nanny-style tutorial: Install Android studio on MAC (including installing JDK, Android SDK) to solve the problem of slow gradle download

Reference article

Original link
Original link

Install JDK and configure environment variables

Install JDK

Download address
Double-click the installation package after downloading
Insert image description here

Insert image description here

Insert image description here

Insert image description here

Insert image description here

Configure JDK related environment variables

Open the Mac terminal and enter the command to query the installation path of the JDK.
Before configuring the environment, you need to know the installation path of the JDK. If you know it, there is no need to check it.

/usr/libexec/java_home -V

Insert image description here
Enter the above string, and the JDK installation path will be output. Copy this path and use it later.

Then we enter the corresponding statement in the terminal: If we configure environment variables for the first time, please enter

touch .bash_profile

A hidden file of .bash_profile will be created. If it is not the first time to configure environment variables, please use it directly.

open -e .bash_profile

Note: The file name must be .bash_profile, and command lines such as touch .bash_profile, open .bash_profile, source .bash_profile must be executed under the Home path. The terminal program defaults to the Home path when it is opened. But if it is not under the Home path, you need to return to the Home path.

The system will automatically read ~/.bash_profile at the beginning, which is the specified file under the Home file. So this requires us to write it under the Home file, and the name must be bash_profile.

Here's what it would look like if the environment variables were first created on the system:

Insert image description here
When you enter open -e .bash_profile and click Enter, a file will appear for us to edit. Enter the following code
JAVA_HOME. You need to write this sentence yourself (paste the path you just copied)

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH%   

Insert image description here
After writing, save the file and close it.
Then return to the terminal and enter the following statement to make the configuration just written take effect.

source .bash_profile 

Insert image description here
Finally, we can enter the java -version statement in the terminal to confirm whether the configuration takes effect.

 java -version

Insert image description here
If the above content is printed out, it means that the environment variables are configured successfully.

Android studio installation

Download Android studio

Download Android studio
and choose Intel or Apple chip according to your computer chip type. Download the corresponding installation package and drag it in. After
Insert image description here
downloading, double-click and this will appear
Insert image description here
. Pull the software to applications to let the software go to the launcher.
Insert image description here
Insert image description here

Solution to slow gradle download

After starting the software and opening the project, you still need to install some things. It takes a long time to open it for the first time. Insert image description here
You can download the required gradle version online and import it into
the gradle official website
Insert image description here
. Download it and then enter it in the Mac terminal.

open .gradle

Note:
Insert image description here
Then, put the downloaded gradle compressed package in the wrapper/dists/ path without decompressing it . Mine has already been installed, so it is decompressed.

Insert image description here
After setting it up, run Android studio to download it quickly.

Install Android SDK

Select jdk version

Menu->Android Studio->Preferences

Build, Execution, Deployment->Build Tools->Gradle

The jdk version can be switched.
Insert image description here

Install the SDK and configure environment variables

Menu->Android Studio->Preferences

Appearances & Behavior->System Settings->Android SDK

If you install SDK, select the version to be installed and click the Apply button to start downloading and installation.
Insert image description here

Configure the sdk environment variables, open the .bash_profile file, and add the following content: (The specific sdk path can also be viewed in Android Studio)

export ANDROID_HOME=/Users/用户名/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin

at last

source .bash_profile

After installing the Android sdk, the adb command can be used normally.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_74239923/article/details/133759807