Note: This article was translated with the assistance of AI. I wrote the original in Chinese. If you can read Chinese, you are welcome to read the original Chinese version for the most authentic and unfiltered expression.

Body

Method 1: Temporary command-line approach

1
sdkmanager --verbose --no_https --proxy=http --proxy_host=<host> --proxy_port=<port> "<package>"

Where:

  • proxy_host is the proxy host; use 127.0.0.1 for local.
  • proxy_port is the proxy port.
  • Append the dependencies you want to install at the end.

Method 2: Permanent modification (requires editing the .bat file)

I’m using Windows; other systems should be similar.

  1. Locate the file:

    1
    2
    # Windows
    %ANDROID_HOME%\cmdline-tools\latest\bin\sdkmanager.bat
  2. Find the line containing %CMD_LINE_ARGS%, near the end of the file, starting with "%JAVA_EXE%" %DEFAULT_JVM_OPTS%.

  3. Change it to:

1
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS% -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli --verbose --no_https --proxy=http --proxy_host=<host> --proxy_port=<port> %CMD_LINE_ARGS%

Remember to adjust the relevant parameters inside.

After this configuration, every time you use sdkmanager from the command line, the proxy will be applied automatically.