Install Android Studio

(1) Download Android Studio

Download address: developer. The android. Google. Cn/studio /

Download the latest DMG file, install it, and click Next until you’re done.

(2) Set Proxy

  1. Open your newly installed Android Studio
  2. Click on the Android Studio
  3. Select the Preferences
  4. Select HTTP Proxy
  5. Select Manual Proxy Configuration -HTTP
  6. Set Host name to mirrors.neusoft.edu.cn
  7. Enter Port number: 80
  8. Click Apply in the lower right corner
  9. Click OK in the lower right corner

Install Gradle

Download Gradle

Download the latest Gradle file directly from the official website.

Download address: services.gradle.org/distributio…

Select Gradle -(version number)-all.zip to download. Note: Android Studio requires the minimum version of Gradle to be 4.1. An error will be reported if the version is later than that.

Put Gradle in Android Studio

  1. Find the Android Studio App in the Applications directory for your Mac and right-click to display the package contents. Find the Contents/gradle directory. If there is no gradle folder in the Contents folder, create it manually. Put the downloaded gradle.zip file decompressed into Contents/gradle directory.
  2. Good will download gradle.zip in Contents/gradle/gradle – X.X.X/wrapper/dist/gradle – X.X.X XXXXXXXXX/directory. Be careful not to unzip.

3. Configure the bash_profile file

  1. Go to the home directory of the current user
cd ~/
Copy the code
  1. Create the bash_profile command
touch .bash_profile
Copy the code
  1. Edit the bash_profile file and enter the following command
open .bash_profile
Copy the code
  1. Configure global environment variables
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-6.22.
export PATH=${PATH}:${GRADLE_HOME}/bin
Copy the code

(Note: Android Studio. App has a space in the middle of the link, and the path cannot contain special characters such as space. You need to add \ before the space to convert, as above)

  1. CMD + s To save the file, go to the terminal window, and run the following command
source .bash_profile
Copy the code
  1. To view the gradle version, run the following command on the terminal
gradle -v
Copy the code

If the following figure appears, gradle configuration is successful

  1. Finally, Android Studio configures Gradle

In Android Studio, select Preferences, find the Gradle option on the left side of the window and select, Configure Gradle User Home: / Applications/Android Studio. The app/Contents/gradle/gradle – 6.2.2, click on the lower right corner of the Apply, and then click OK in the lower-right corner of the window.

(4) Attention

  1. If in step 6, the query for gradle version number is not successful, becausegradleandgradle.batThe execution permission is insufficient. Modify the permission. Execute command:
cd /Applications/Android\ Studio.app/Contents/gradle/gradle-6.22./bin
Copy the code
ls -l
Copy the code

  1. If there is none in the red circle abovexI have no executable permission, because I have added permission, so I have executable permission. Run the following commands in sequence to add the execution permission.
chmod +x gradle
chmod +x gradle.bat
Copy the code
  1. Finally, restart the Mac Terminal or enter Gradle -v in the Android Studio Terminal. The output shows that the configuration is successful.

  2. If it fails, it is because Android Studio does not have the JDK configured.

To obtain the JDK installation directory, run the following command:

/usr/libexec/java_home
Copy the code
  1. If you can’t find the JDK installation path, go to the official website to download the JDK and install it.

Download address: www.oracle.com/cn/java/tec…

After the installation is successful, run commands

/usr/libexec/java_home
Copy the code

Get the JDK installation path and then configure the bash_profile file.

  1. Edit the bash_profile file and enter the following command
open .bash_profile
Copy the code
  1. Configure global environment variables
JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/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
Copy the code

(Note: the path after JAVA_HOME is where you installed the JDK.)

  1. CMD + s To save the file, go to the terminal window, and run the following command
source .bash_profile
Copy the code
  1. To view the gradle version, run the following command on the terminal
gradle -v
Copy the code

If the following figure appears, gradle configuration is successful

Configure the SDK

(1) Download the SDK

  1. Download the SDK and configure the SDK directory into Android Studio

  1. To configure SDK Update Sites, add the following link:
http://mirrors.neusoft.edu.cn/android/repository/addon-6.xml
http://mirrors.neusoft.edu.cn/android/repository/addon.xml
http://mirrors.neusoft.edu.cn/android/repository/extras/intel/addon.xml
http://mirrors.neusoft.edu.cn/android/repository/sys-img/android-tv/sys-img.xml
http://mirrors.neusoft.edu.cn/android/repository/sys-img/android-wear/sys-img.xml
http://mirrors.neusoft.edu.cn/android/repository/sys-img/android/sys-img.xml
http://mirrors.neusoft.edu.cn/android/repository/sys-img/google_apis/sys-img.xml
http://mirrors.neusoft.edu.cn/android/repository/sys-img/x86/addon-x86.xml
http://mirrors.neusoft.edu.cn/android/repository/addons_list-2.xml
http://mirrors.neusoft.edu.cn/android/repository/repository-10.xml
Copy the code

2. Configure the SDK in the basn_profile file

export ANDROID_HOME=/Users/xxx/devtools/SDK
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Copy the code

Build the project

If the building project times wrong, unable to download com. The android. View the build: gradle: X.X.X ‘” HTTP / 1.1 400 Bad Request such information. So set up the Http Proxy.

Five, the summary

Done!!