You may need to adjust the proxy settings in Gradle

Gradle logo

To adjust the proxy settings in Gradle, you will need to edit the gradle.properties file, which should be located in the .gradle directory in your home directory. This file allows you to specify various settings for Gradle, including the proxy settings.

To set the proxy settings, you can add the following lines to the gradle.properties file to the location Preferences > Settings > Appearance & Behavior > System Settings > HTTP Proxy Enable following option Auto-detect proxy settings:

apply plugin: 'com.android.application'

android {
    ...

    defaultConfig {
        ...
        systemProp.http.proxyHost=proxy.company.com
        systemProp.http.proxyPort=443
        systemProp.http.proxyUser=userid
        systemProp.http.proxyPassword=password
        systemProp.http.auth.ntlm.domain=domain
    }
    ...
}

If you are using an http proxy server, revise the following proxy settings in “gradle.properties” file in your project’s root folder. If not using proxy server, just delete those entries.

systemProp.http.proxyPort=8080
systemProp.http.proxyUser=UserName
systemProp.http.proxyPassword=Passw0rd
systemProp.https.proxyPassword=Passw0rd
systemProp.https.proxyHost=proxy.company.com
systemProp.http.proxyHost=proxy.company.com
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=UserName

OR

Update your project level build.gradle to latest version – it works for some people.

classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'

Make sure to replace proxy.company.com with the hostname of your proxy server, and 8080 with the port number of your proxy server. Also, replace username and password with your proxy login credentials. The nonProxyHosts property allows you to specify a list of hosts that should be accessed directly, rather than through the proxy.

After making these changes, save the file and then try running Gradle again. The proxy settings should now be in effect.

If you are using a version of Gradle that is earlier than 3.5, you can also specify the proxy settings using the -D command-line option. For example:

gradle -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password -Dhttp.nonProxyHosts=localhost|*.company.com build

Hope it works. we took the reference of Stackoverflow.com Most of the information.

Leave a Comment