Android Studio Agent Configuration Guide of Summary

  • 2021-11-01 04:41:59
  • OfStack

Android Studio user agent configuration guide, the real effective gradle agent configuration. # Dependence can't be pulled down. It really makes people autistic. I don't want to be autistic again and again, so write it down.

IDE HTTP Proxy

Under Windows, Ctrl + Alt + S, then enter Proxy to see the settings of HTTP and Proxy. The specific path is Appearance & Behavior > System Settings > HTTP Proxy, Preferences corresponds to Settings on the other side of macOS.

In most cases, you should use Shadowsocks as the proxy client. If so, do this next:

Select Socks under Manual proxy configuration, then fill in Host name (1 is 127.0. 0.1) and Port number, and then try Check connection for 1 time. Here is mainly Android Studio for their own configuration, check updates, report usage and so on.

Gradle Proxy

Replace maven warehouse
Edit build. gradle under the root directory of the project, modify the contents of repositories block, and add maven image of Alibaba Cloud. After modification, the file looks like this:


buildscript {
  ext.kotlin_version = '1.3.11'
  repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    google()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}

allprojects {
  repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    google()
  }
}

Configure Agent

Configuring Alibaba Cloud maven image can speed up synchronization and solve most of the problems, but some things may still rely on Google repository (although dl. google. com seems to be directly connected again), but various problems may arise from time to time. Therefore, it is necessary to configure the following agents.
The most popular way to set up proxies is to add such configuration in gradle. properties:


systemProp.socks.proxyHost=127.0.0.1
systemProp.socks.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080

However, the above setting is not valid for socks proxy. Next, you can try to add:


systemProp.https.proxyHost=socks5://127.0.0.1
systemProp.https.proxyPort=1080

Of course, it may not work. If it doesn't work, change it to:


org.gradle.jvmargs=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1080

Plan pass!

Change the global configuration

Applying the above changes to ~\. gradle\ gradle. properties (this is the default location for the gradle global configuration on Window) will take effect for all projects

Transparent proxy

This is a better choice, or it is also good to use VPN to connect back to the company.


Related articles: