- Gradle sync issue on Debian OS due to user does not have permission
- Android Gradle Plugin 3.0+ sync issue
Basically, there are TWO kind of proxies you need to configure for your gradle to work properly behind a proxy, i.e. fetching the online dependencies.
- proxy for gradle
- proxy for maven
Let’s assume that the proxy server and port number are as below:
- proxy: my-example-proxy.com
- port: 8080
Proxy for gradle
Under your Android project root directory, find gradle.properties file and add below settings:
systemProp.http.proxyHost=my-example-proxy.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=my-example-proxy.com systemProp.https.proxyPort=8080 # Add all your hosts that should be bypassed by your proxy server. systemProp.https.nonProxyHosts=localhost
Note that this proxy setting will apply to your gradle build commands as well.
Proxy for Maven
Because many dependencies are hosted on maven repositories, you also need to configure the maven proxy properly.
Go to the hidden maven repository directory “.m2” which is usually under your home directory “~/.m2“. If you don’t have this directory, please create it and then create the required maven setting file “~/.m2/settings.xml” with below content.
<?xml version="1.0" encoding="UTF-8"?> <!-- To configure encrypted password see: http://maven.apache.org/guides/mini/guide-encryption.html --> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <proxies> <proxy> <id>Proxy server</id> <active>true</active> <protocol>http</protocol> <host>my-example-proxy.com</host> <port>8080</port> <nonProxyHosts>localhost</nonProxyHosts> </proxy> <proxy> <id>Proxy server</id> <active>true</active> <protocol>https</protocol> <host>my-example-proxy.com</host> <port>8080</port> <nonProxyHosts>localhost</nonProxyHosts> </proxy> </proxies> </settings>
These two proxy settings for gradle and maven should resolve your proxy issues for fetching online dependencies.
But if you get used to command line, then probably the proxy for bash need to be configured as well.
Proxy for bash
Go to the home directory to find ~/.bashrc or ~/.bash_profile. Open it using your preferred text editor and paste below settings.
export http_proxy=my-example-proxy.com:8080 export https_proxy=my-example-proxy.com:8080