Android emulator binary can not set proxy server

Recently, I encountered a bug with the Android emulator. It’s not properly setting the proxy server when passing values through the command line:

1
emulator -avd Android_11 -writable-system -http-proxy 127.0.0.1:8090

The following warning was displayed:

1
2
WARNING | Could not connect to proxy at :8080: No such file or directory !
WARNING | Proxy will be ignored !

A bug report has been filed on this issue, which suggests that the problem can only be addressed by reverting to emulator version 33.1.10. You can download this specific version from the Android Emulator Archive and follow the instructions outlined on the webpage.

For those looking for a quick fix, here’s the script for that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cd $ANDROID_HOME
arch=$(uname -m)
# search for 33.1.10 at https://developer.android.com/studio/emulator_archive and change the below url for your CPU arch type
if [ "$arch" == "x86_64" ]; then
link=https://redirector.gvt1.com/edgedl/android/repository/emulator-darwin_x64-10078095.zip
else
link=https://redirector.gvt1.com/edgedl/android/repository/emulator-darwin_aarch64-10078095.zip
fi
wget $link
mv emulator emulator-original
unzip emulator-darwin_aarch64-10078095.zip
xattr -dr com.apple.quarantine emulator/
cp emulator-original/package.xml emulator/package.xml

# replace version at the bottom of emulator/pacakge.xml to <major>33</major><minor>1</minor><micro>10</micro>
sed -E 's/<major>[0-9]+<\/major><minor>[0-9]+<\/minor><micro>[0-9]+<\/micro>/<major>33<\/major><minor>1<\/minor><micro>10<\/micro>/g' emulator-original/package.xml > emulator/package.xml

This script effectively resolves the issue, ensuring that the -http-proxy values are correctly applied when you launch the emulator with command line or use the emulator’s settings option.


Android emulator binary can not set proxy server
https://automationlog.in/Android-emulator-cant-set-proxy-server.html
Author
Prabhash Singh
Posted on
January 30, 2024
Licensed under