Configure Proxy on Unix terminal to accelerate Android Studio Construction

Source: Internet
Author: User

Configure Proxy on Unix terminal to accelerate Android Studio Construction

How slow is the jar package downloaded by Gradle? Half of Github synchronization is disconnected? Frequent Docker download error? It is time to set up a proxy for your terminal. This article uses Mac (Unix platform) and HTTP_PROXY as an example to explain how to configure proxy under the terminal.

This article belongs to the note type, and the quality is far inferior to that of technical articles. However, there is not much reliable information about this content on the Internet, so it is recorded.

1. Select Proxy

First, you need to purchase and select a Proxy. before buying a Proxy, you must note that the service provider must be able to provideHttp ProxyAs follows, a conscientious service provider provides multiple configuration methods


Proxy_list2. Configure the terminal
  1. Open Terminal

     open -t  ~/.bash_profile

    . Bash_profile can be understood as a script file that can be automatically executed after the Term is opened.

  2. Add the following content in the text

#ideaexport JAVA8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Homeexport JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Homeexport JAVA_HOME=$JAVA8_HOME#Androidexport ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1export ANDROID_SDK=$ANDROID_HOMEexport ANDROID_NDK=/usr/local/Cellar/android-ndk/r10e#http proxyHOST=www.xxx.comPORT=xxxx#if use lantern, removes comments# LANTERN=127.0.0.1 # HOST=$LANTERN# PORT=8787export http_proxy=http://$HOST:$PORTexport all_proxy=$http_proxyexport https_proxy=$http_proxyexport ftp_proxy=$http_proxyexport dns_proxy=$http_proxyexport rsync_proxy=$http_proxyexport no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com,.coding.net,192.168.99.100"#java(works fine on gradle/mvn/android)export JAVA_OPTS="-Dhttp.proxyHost=$HOST -Dhttp.proxyPort=$PORT -Dhttps.proxyHost=$HOST -Dhttps.proxyPort=$PORT"#gradle will use `JAVA_OPTS` as concatexport GRADLE_OPTS="-Dgradle.user.home=$HOME/.gradle"#mavenexport MAVEN_OPTS=$JAVA_OPTScurl ip.cn
  1. Save Configuration

     source ~/.bash_profile

    After this method is configured, it is also useful in terminals of tools such as IDEA.

3. view results

After you re-open the terminal, you can find that the system automatically executes the curl command. This website will automatically tell you the current IP address. We can also use wget for SpeedTest.

wget -O /dev/null http://speedtest-sfo1.digitalocean.com/10mb.test

Speed_test_digital_ocean

Finally, try to download Git, Brew, Gradle, and other tools quickly!

Note:

  1. In the Docker environment of Mac, you need to configure the Proxy in the virtual machine/VPS.
  2. You can use Go, Git, Brew, Curl, Wget, and NPM for physical bandwidth.
  3. Not Supportedgit://Andsvn://The two have to build one by themselves and one packaging class, so forget it.
  4. If you need to set a regular expression (such as 172, 10,) for the Intranet address, there is no perfect solution for the moment. You can only enumerate and manually addno_proxyMedium
  5. Gradle is java-related and does not use curl.GRADLE_OPTSAs an environment variable, note that this environment variable is only a terminal, not an IDE
4. AndroidStudio project instance

Open Terminal

git clone --depth=1 https://github.com/Yalantis/StarWars.Android.gitcd StarWars.Android/./gradlew build --debug

Because there is a high-speed Proxy, the download dependency is very fast. After the download is successful, open AndroidStudio to import the current ready-made project, you can reuse the cache insteadBuildingDialog Box

5. Ping for Speed Testing
# Proxy arraySERVER = (www.xx.com www.xx2.com) for s in $ {SERVER [*]} do echo testing $ s rank [$ counter] =$ (ping-c 4 $ s | awk-F'/''end {print $5 }') donemin = 0for I in "$ {! Rank [@]} "; do if [$ (bc <" $ {rank [$ min] >$ {rank [$ I]} ") = 1]; then let min = $ I fidoneecho "best proxy is $ {SERVER [$ min]}, ping is $ {rank [$ min]} "HOST =$ {SERVER [$ min]} PORT = xxxx # export

For more information about Android Studio, see the following links:

Install Android Studio in Ubuntu 15.04

The simulator in Android Studio 2.0 has been increased by 50 times.

Full process of installing Android Studio on Ubuntu 12.04 (64-bit)

Early adopters of Android Studio v0.1

Android Studio tutorial

Android Studio Development Guide

How to solve the problem that Android Studio sets the topic and does not support Chinese Characters

Android Studio download and installation and solutions that cannot be opened

Graphic tutorial for installing Android Studio

Install Android Studio 1.3 on Ubuntu (developed by Google Android IDE)

Android Studio details: click here
Android Studio: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.