How to set proxy authentication for Android sdkman

2019-06-21 20:56发布

问题:

I want to pass proxy authentication (username and password) along with proxyhost and proxyport

currently Android sdkmanager supports --proxy_host and --proxy_port (in command line)

our proxy server has authentication also (username and password)

Thanks in advance.

回答1:

On Linux, you can export proxy environment variable, then run sdkmanager command

export http_proxy=http://[USERNAME]:[PASSWORD]@[PROXY_ADDRESS]:[PROXY_PORT]

For https proxy

export https_proxy=https://[USERNAME]:[PASSWORD]@[PROXY_ADDRESS]:[PROXY_PORT]

If the above command does not work, try

_JAVA_OPTIONS="-Dhttp.proxyHost=[PROXY_ADDRESS] -Dhttp.proxyPort=[PROXY_PORT] -Dhttp.proxyUser=[USERNAME] -Dhttp.proxyPassword=[PASSWORD]" bash -c "sdkmanager '[SDK_COMPONENT]'"

This is because command sdkmanager will run as a normal java application. It will apply the options you specified in the command line.



回答2:

One thing I suggest you do is this.

Goto

Settings->Appearance and Behaviour->System settings-> HTTP Proxy

Change the settings there. Hope this helps.

Also, you could try the following code from the command line.

sdkmanager --list --verbose --no_https --proxy=http --proxy_host=<proxy_host> --proxy_port=<proxy_port>