### Install Dependencies Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md Command to install project dependencies, typically used before starting the development environment. ```Shell make deps ``` -------------------------------- ### Start Development Environment Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md Commands to start the development environment, including Envoy and Node.js, which serves the React application and enables hot reloading. ```Shell make develop ``` -------------------------------- ### Compiling Protoc Plugins with Make Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This sequence of shell commands shows the steps to compile and install protoc plugins after ensuring the environment is correctly set up (e.g., `PKG_CONFIG_PATH`). It involves navigating to the plugin directory, running `make`, and then `sudo make install`. ```sh cd js/protoc-plugin make sudo make install ``` -------------------------------- ### Example Docker log output for TURN connection (Log) Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD An example log line from the Android emulator container indicating that the TURN server configuration has been successfully sent to the browser clients. This confirms that the TURN setup is working. ```text video: (Switchboard.cpp:264): Sending {"msg":{"start":{"iceServers":[{"credential":"turnpassword","urls":"turn:","username":"webrtc"}]}},"topic":"c6965c12-8b72-45c3-bc7d-f8143488382a"} ``` -------------------------------- ### Install Emulator Build from Zip Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md This command demonstrates how to unzip an emulator build package to the specified Android SDK root directory. It is used to update or install a specific emulator version. ```sh $unzip ~/Downloads/sdk-repo-linux-emulator-5775474.zip -d $ANDROID_SDK_ROOT ``` -------------------------------- ### Start Web Containers with Default Configuration Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Launches the Docker Compose stack defined in 'docker-compose.yaml' to start the web-accessible emulator environment. This command brings up all services defined in the compose file. ```bash docker-compose -f js/docker/docker-compose.yaml up ``` -------------------------------- ### Running the Android Emulator Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/emu/templates/registry.README.MD Provides an example command to run the Android Emulator container. It exposes necessary ports for ADB and gRPC, and maps the KVM device for hardware acceleration. ```bash docker run -e "ADBKEY=$(cat ~/.android/adbkey)" --device /dev/kvm --publish 8554:8554/tcp --publish 5554:5554/tcp --publish 5555:5555/tcp {{first_image}} ``` -------------------------------- ### Launch Android Emulator from Repository Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Starts an Android emulator directly from a Docker image that has been pushed to a repository. It includes KVM acceleration and port forwarding. ```Shell docker run --device /dev/kvm --publish 8554:8554/tcp --publish 5555:5555/tcp \ us.gcr.io/emulator-project/29-playstore-x86:30.1.2 ``` -------------------------------- ### Start Web Containers with ADB Access Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Starts the Docker Compose stack, including the additional 'development.yaml' overlay to enable ADB access to the emulator. This allows interaction with the emulator via ADB commands. ```bash docker-compose -f js/docker/docker-compose.yaml -f js/docker/development.yaml up ``` -------------------------------- ### Run Android Emulator Docker Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/emu/templates/emulator.README.MD Example command to run an Android Emulator container, exposing console, ADB, and gRPC ports, and setting environment variables for authorization token and ADB key. ```sh docker run -e "TOKEN=$(cat ~/.emulator_console_auth_token)" -e "ADBKEY=$(cat ~/.android/adbkey)" -e "EMULATOR_PARAMS=${PARAMS}" --device /dev/kvm --publish 8554:8554/tcp --publish 5554:5554/tcp --publish 5555:5555/tcp ${CONTAINER_ID} ``` -------------------------------- ### Configuring TURN Server for Android Emulator WebRTC Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This documentation explains how to configure TURN settings for the Android emulator when a TURN server is required, typically in restricted network environments. It shows how to get help for TURN configuration and how to pass the configuration to the emulator via docker. ```bash $ANDROID_SDK_ROOT/emulator/emulator -help-turncfg ``` ```bash emu_docker create --help ``` -------------------------------- ### Running Android Emulator Docker Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/REGISTRY.MD An example of how to run an Android Emulator Docker container, exposing necessary ports for ADB and gRPC. It includes setting the ADBKEY environment variable and mapping the KVM device for hardware acceleration. ```bash docker run -e "ADBKEY=$(cat ~/.android/adbkey)" --device /dev/kvm --publish 8554:8554/tcp --publish 5554:5554/tcp --publish 5555:5555/tcp us-docker.pkg.dev/android-emulator-268719/images/28-playstore-x64:30.1.2 ``` -------------------------------- ### Static TURN Configuration for Emulator Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD This snippet illustrates the final command-line flag passed to the Android emulator for static TURN configuration. It's an example of how the `--extra` argument from the build-time process is interpreted, embedding a JSON structure for ICE servers. ```shell -turncfg 'printf {"iceServers":[{"urls":"turn:","username":"webrtc","credential":"turnpassword"}]}' ``` -------------------------------- ### Interactively Start Emulator Docker Image Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Initiates an interactive process to select Android system images and emulator versions, generating a Dockerfile and providing commands to manage the container. ```sh emu-docker interactive --start ``` -------------------------------- ### Setting PKG_CONFIG_PATH for Protobuf with Homebrew Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This shell command demonstrates how to set the `PKG_CONFIG_PATH` environment variable to include Homebrew's pkgconfig directory when it might not be found automatically. This is crucial for compiling protoc plugins if protobuf libraries are installed in an uncommon location. ```sh export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(find $(brew --prefix) -name 'pkgconfig' -print | grep protobuf) ``` -------------------------------- ### Launch coturn TURN server (Bash) Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Launches the coturn TURN server with specified logging and realm. The TURN_SERVER environment variable should be set to your publicly accessible TURN server hostname. Note: This example uses an insecure configuration for simplicity; production use requires password protection. ```bash export TURN_SERVER="localhost" # This should be your real host name! turnserver -v -n --log-file=stdout -r $TURN_SERVER ``` -------------------------------- ### Execute ADB Shell Command Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Example of executing an ADB shell command after connecting to the emulator. This command retrieves system properties of the Android device. ```bash $ adb shell getprop ``` -------------------------------- ### Embed TURN Configuration at Build Time Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD This example shows how to embed a static TURN configuration directly into a Docker container during the build process using the 'emu-docker create' command. The '--extra' flag is used to pass the configuration, which is then escaped for proper parsing by the emulator. This method ensures the configuration is present by default. ```shell emu-docker create canary \ "R" \ --extra \ '-turncfg '\'printf {"iceServers":[{"urls":"turn:","username":"webrtc","credential":"turnpassword"}]}'\'' ' ``` -------------------------------- ### Configure TURN via Environment Variable at Runtime Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD This snippet demonstrates how to pass a TURN configuration command to the Android emulator at runtime using the 'TURN' environment variable. The example uses 'curl' to fetch the configuration from a remote URL. Ensure the provided URL and API key are correct. ```shell docker run \ -e ADBKEY="$(cat ~/.android/adbkey)" \ -e TURN="curl -s -X POST https://networktraversal.googleapis.com/v1alpha/iceconfig?key=mykey" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp ${CONTAINER_ID} ``` -------------------------------- ### Run Android Emulator Container in Detached Mode Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Starts an Android emulator container in the background (detached mode) and configures ADB to connect to it. Waits for the device to become available. ```sh docker run -d \ -e ADBKEY="$(cat ~/.android/adbkey)" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp \ us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2 adb connect localhost:5555 adb wait-for-device ``` -------------------------------- ### Launch Python REST API Server Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Starts a Python REST API server to provide secure TURN configurations. It requires API keys and secrets for authentication between the emulator, API, and TURN server. The server listens on a specified port. ```shell export API_KEY="a_secret_the_emulator_needs" export SECRET="a_secret_that_the_turn_server_needs" python turn.py --turn_secret $SECRET --api_key $API_KEY --port 8080 ``` -------------------------------- ### Troubleshoot ADB Not Found Error in Python Script Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This Python traceback indicates a FileNotFoundError because ADB could not be located. The error message explicitly states that ADB is not found below $ANDROID_SDK_ROOT or on the system's PATH, suggesting a missing ADB installation. ```python Traceback (most recent call last): File "/tmp/android-emulator-container-scripts/venv/bin/emu-docker", line 11, in load_entry_point('emu-docker', 'console_scripts', 'emu-docker')() File "/tmp/android-emulator-container-scripts/emu/emu_docker.py", line 123, in main args.func(args) File "/tmp/android-emulator-container-scripts/emu/emu_docker.py", line 48, in create_docker_image_intere device.create_docker_file(args.extra) File "/tmp/android-emulator-container-scripts/emu/docker_device.py", line 119, in create_docker_file raise IOError(errno.ENOENT, "Unable to find ADB below $ANDROID_SDK_ROOT or on the path!") FileNotFoundError: [Errno 2] Unable to find ADB below $ANDROID_SDK_ROOT or on the path! ``` -------------------------------- ### Create Web Container Script Help Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Displays the help message for the 'create_web_container.sh' script, outlining its usage and optional arguments for customizing container creation and execution. ```bash $ ./create_web_container.sh -h ``` -------------------------------- ### Prepare Docker build context with emulator and system image Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md The `emu-docker create` command takes paths to emulator and system image zip files to prepare a directory structure suitable for Docker image building. It requires a Linux emulator zip. The destination directory defaults to `./src`. ```shell emu-docker create [--dest docker-src-dir] ``` -------------------------------- ### Show Emulator Script Help Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Displays the help message for the 'emu-docker' command-line tool, outlining its usage and options. ```sh emu-docker -h ``` -------------------------------- ### Launch Emulator with a Virtual Device Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md This command launches an Android Emulator with a specified Android Virtual Device (AVD) named 'P'. It assumes the emulator executable is in the PATH or ANDROID_SDK_ROOT is set. ```sh $ANDROID_SDK_ROOT/emulator/emulator @P ``` -------------------------------- ### Launch GCE Instance with Android Emulator Source: https://github.com/google/android-emulator-container-scripts/blob/master/cloud-init/README.MD Launches a Google Compute Engine instance with nested virtualization enabled, using a custom COS image, and configures Android emulator ports and ADB key via instance metadata. The `cloud-init` file is provided as user-data. ```sh gcloud compute instances create aemu-example \ --zone us-west1-b \ --min-cpu-platform "Intel Haswell" \ --image cos-dev-nested \ --machine-type n1-highcpu-32 \ --tags=http-server,https-server \ --metadata-from-file user-data=cloud-init \ --metadata=emulator_adbkey="$(cat ~/.android/adbkey)",emulator_adb_port=80,emulator_grpc_port=443 ``` -------------------------------- ### Create GCE Disk and Image with Nested Virtualization Source: https://github.com/google/android-emulator-container-scripts/blob/master/cloud-init/README.MD This snippet demonstrates using `gcloud` commands to create a new Compute Engine disk from an existing COS image and then create a new custom image from that disk. The key aspect is the `--licenses` flag, which enables nested virtualization (VMX) for the new image. ```bash gcloud compute disks create cos-dev-nested-disk --image emu-dev-cos-base --zone us-west1-b gcloud compute images create cos-dev-nested --source-disk cos-dev-nested-disk --source-disk-zone us-west1-b --licenses "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx" ``` -------------------------------- ### Run Web Container Script Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Executes the 'create_web_container.sh' script to set up the necessary Docker containers for web access to the Android emulator. This includes creating a virtual environment and the container set. ```bash ./create_web_container.sh ``` -------------------------------- ### Create Emulator Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md Command to create a containerized version of the Android emulator using the emu-docker tool. It specifies the stability channel and the emulator image details. ```Shell emu-docker create stable "Q google_apis_playstore x86" ``` -------------------------------- ### Launch Emulator with WebRTC Support Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md This command launches an Android Emulator with a specified AVD and activates gRPC support on port 8554, which is required for WebRTC communication. The port needs to be accessible by the gRPC proxy. ```sh $ANDROID_SDK_ROOT/emulator/emulator @P -grpc 8554 ``` -------------------------------- ### Build Docker image from prepared context Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md This command builds a Docker image using the prepared source directory (`docker-src-dir`). It utilizes the standard `docker build` command to create a runnable Android emulator environment within a container. Ensure you have the necessary Docker environment set up. ```shell docker build ``` -------------------------------- ### Test TURN Server Configuration with jq Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Tests the TURN server configuration by fetching a generated ICE configuration from the API and using jq to format it for the turnutils_uclient command. This verifies the communication and authentication between the API and the TURN server. ```shell curl -s "http://localhost:8123/turn/localhost?apiKey=$API_KEY" | \ jq '.iceServers[0] | "turnutils_uclient -w \(.credential) -u \(.username) $TURN_SERVER"' ``` -------------------------------- ### Create Android Emulator Docker Image Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Command to create a Docker image for the Android emulator with a specified build channel and device architecture. Requires the 'configure.sh' script to be sourced first. ```bash . ./configure.sh && emu-docker create canary "P.*x86_64" ``` -------------------------------- ### Launch Android Emulator Container with TURN config (Bash) Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Launches the Android emulator container using Docker. It mounts the ADB key, sets the TURN server configuration via the TURN environment variable, and exposes necessary ports. The SNIPPET environment variable must contain the JSON configuration as a single line. ```bash export SNIPPET="{\"iceServers\":[{\"urls\":\"turn:$TURN_SERVER\",\"username\":\"webrtc\",\"credential\":\"turnpassword\"}]}" docker run \ -e ADBKEY="$(cat ~/.android/adbkey)" \ -e TURN="printf $SNIPPET" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp ${CONTAINER_ID} ``` -------------------------------- ### Pulling an Android Emulator Docker Image Source: https://github.com/google/android-emulator-container-scripts/blob/master/emu/templates/registry.README.MD Demonstrates how to pull a pre-built Docker image for the Android Emulator from a container registry. This is the first step before running the emulator. ```bash docker pull {{first_image}} ``` -------------------------------- ### Verify TURN server connection in Docker logs (Bash) Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD A command to check the Docker logs for a specific container to verify the TURN server connection. It searches for a log line containing 'Switchboard.cpp' which indicates successful ICE server configuration being sent. ```bash docker logs my_container_id | grep Switchboard.cpp ``` -------------------------------- ### Run Hosted Android Emulator Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Launches a pre-built Android emulator container from a public registry. Requires Docker and ADB. Connects to the emulator via ADB after launch. ```sh docker run \ -e ADBKEY="$(cat ~/.android/adbkey)" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp \ us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2 ``` -------------------------------- ### Launch Public TURN Server Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Launches a public coTURN server with secure authentication using a shared secret. It configures the server to log to stdout and specifies the realm for authentication. ```shell export TURN_SERVER="localhost" # This should be your real host name! turnserver -v -n --log-file=stdout \ --use-auth-secret --static-auth-secret=$SECRET -r $TURN_SERVER ``` -------------------------------- ### List Android emulator/system image URLs Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md The `emu-docker list` command queries published Android SDK data to provide URLs for downloadable zip files of system images and emulator binaries. It details API level, variant, ABI, update channel, version, and host OS for each. ```shell emu-docker list ``` -------------------------------- ### Extracting Notices from Android Emulator Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/emu/templates/registry.README.MD Shows how to extract NOTICE.txt files from an Android Emulator Docker image. This is useful for understanding the licensing and attributions of the included software. ```bash CONTAINER_ID=$(docker create name_of_image) docker export $CONTAINER_ID | tar vxf - --wildcards --no-anchored 'NOTICE.txt' ``` -------------------------------- ### Configure Emulator with Static STUN Server Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Configures the Android emulator to use a static STUN server configuration provided via the `turncfg` flag. This demonstrates a simple, hardcoded configuration for network traversal. ```shell emulator -grpc 8554 -turncfg 'printf {"iceServers":[{"urls":["stun:stun.l.google.com:19302"]}]}' ``` -------------------------------- ### Execute TURN Server Test Command Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Executes the constructed command from the previous step to test the TURN server connection using specific credentials. This verifies the TURN server's ability to handle client connections. ```shell $ turnutils_uclient -w GH7ON8EceVvLtr96vSIB6unYBRM= -u 1598489324:someone localhost ``` -------------------------------- ### Create Android Emulator Docker Image with GPU Acceleration Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Builds a Docker container for the Android emulator with support for NVIDIA GPU acceleration. Requires NVIDIA Docker extensions and potentially an X server like Xvfb. ```Shell emu-docker create stable Q --gpu ``` -------------------------------- ### Activate Virtual Environment for emu-docker Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This command activates the virtual environment for the emu-docker project, resolving 'Unable to find emu-docker' issues by ensuring proper isolation of dependencies. ```sh source ./configure.sh ``` -------------------------------- ### Run Android Emulator Docker Image with KVM Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Launches an Android emulator in a Docker container using KVM for CPU acceleration. It forwards ADB and gRPC ports and sets up the ADB key from the host. ```Shell docker run -e ADBKEY="$(cat ~/.android/adbkey)" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp ``` -------------------------------- ### EmulatorScreen and LogcatView Properties Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md This snippet describes the required properties for EmulatorScreen and LogcatView components, including the URI for the gRPC proxy and an AuthService object for handling authentication headers and unauthorized responses. ```JavaScript { Authorization: "token header" } ``` -------------------------------- ### Check Emulator Version Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/README.md This command checks the build ID of the Android Emulator to ensure it meets the minimum requirement for WebRTC support. It requires the ANDROID_SDK_ROOT environment variable to be set. ```sh $ANDROID_SDK_ROOT/emulator/emulator -version | head -n 1 ``` -------------------------------- ### Launch Emulator Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Launches an Android emulator in a Docker container, configuring it to use the TURN server via an environment variable. It maps necessary ports and devices for emulator operation. ```shell docker run \ -e ADBKEY="$(cat ~/.android/adbkey)" \ -e TURN="curl -s $TURN_API/turn/$TURN_SERVER\?apiKey=$API_KEY" \ --device /dev/kvm \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp ${CONTAINER_ID} ``` -------------------------------- ### Connect to Android Emulator via ADB Source: https://github.com/google/android-emulator-container-scripts/blob/master/cloud-init/README.MD Retrieves the external IP address of a launched GCE instance and connects to the Android emulator running on it using ADB. Assumes the emulator's ADB port is exposed. ```sh IP=$(gcloud compute instances describe aemu-example --format='get(networkInterfaces[0].accessConfigs[0].natIP)') adb connect $IP:80 ``` -------------------------------- ### Create TURN server JSON configuration (JSON) Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD A JSON snippet defining the ICE servers for the emulator. It includes the TURN server URL, username, and password. These credentials depend on your TURN server configuration and are not required for insecure servers. ```json { "iceServers": [ { "urls": "turn:$TURN_SERVER", "username": "webrtc", "credential": "turnpassword", }, ]; } ``` -------------------------------- ### Pulling Android Emulator Docker Image Source: https://github.com/google/android-emulator-container-scripts/blob/master/REGISTRY.MD Demonstrates how to pull a specific Android Emulator Docker image from Google's artifact registry. This command fetches the necessary container image to run the emulator. ```docker docker pull us-docker.pkg.dev/android-emulator-268719/images/28-playstore-x64:30.1.2 ``` -------------------------------- ### Extract Emulator Notices Source: https://github.com/google/android-emulator-container-scripts/blob/master/emu/templates/emulator.README.MD Command to extract NOTICE.txt files for the Android emulator and system images from a Docker container. ```sh CONTAINER_ID=$(docker create {{container_id}}) docker export $CONTAINER_ID | tar vxf - --wildcards --no-anchored 'NOTICE.txt' ``` -------------------------------- ### Diagnosing Docker Image Creation Errors in Python Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This Python traceback indicates a `ConnectionResetError` during Docker image creation, often due to credential helper configuration issues. The suggestion is to run Docker with the `-v` flag to observe authentication attempts. ```python Traceback (most recent call last): File "....python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File ".../python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1065, in _send_output self.send(chunk) File "/usr/lib/python3.6/http/client.py", line 986, in send self.sock.sendall(data) ConnectionResetError: [Errno 104] Connection reset by peer ``` -------------------------------- ### Push Android Emulator Images to Repository Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Pushes custom Android emulator Docker images to a specified repository. Uses parameters like --push, --repo, and --tag for image naming and distribution. ```Shell emu-docker -v create --push --repo us.gcr.io/emulator-project/ stable "Q" ``` -------------------------------- ### Run Android Emulator Docker Image with KVM and tmpfs Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Runs an Android emulator in a Docker container with KVM acceleration and mounts a tmpfs to /data for potentially improved performance, especially in nested virtualization scenarios. ```Shell docker run -e ADBKEY="$(cat ~/.android/adbkey)" \ --device /dev/kvm \ --mount type=tmpfs,destination=/data \ --publish 8554:8554/tcp \ --publish 5555:5555/tcp ``` -------------------------------- ### Run Android Emulator Docker Image with GPU Acceleration Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Launches an Android emulator in a Docker container with NVIDIA GPU acceleration enabled. This script makes GPUs available to the container and configures X11 access. ```Shell ./run-with-gpu.sh ``` -------------------------------- ### Enable KVM in COS Kernel Configuration Source: https://github.com/google/android-emulator-container-scripts/blob/master/cloud-init/README.MD This diff modifies the kernel configuration file (`base.config`) to enable KVM modules (KVM, KVM_INTEL, KVM_MMU_AUDIT, KVM_AMD) and related features like VHOST_NET and VHOST_VSOCK. These changes are necessary for hardware-assisted virtualization within the COS image. ```diff diff --git a/project-lakitu/sys-kernel/lakitu-kernel-5_4/files/base.config b/project-lakitu/sys-kernel/lakitu-kernel-5_4/files/base.config index e13a9e170e..a31b2b73db 100644 --- a/project-lakitu/sys-kernel/lakitu-kernel-5_4/files/base.config +++ b/project-lakitu/sys-kernel/lakitu-kernel-5_4/files/base.config @@ -609,7 +609,13 @@ CONFIG_EFI_EARLYCON=y CONFIG_HAVE_KVM=y CONFIG_VIRTUALIZATION=y -# CONFIG_KVM is not set +# is not set +CONFIG_KVM=m +CONFIG_KVM_INTEL=m +CONFIG_KVM_MMU_AUDIT=m +CONFIG_KVM_AMD=m +CONFIG_VHOST_NET=m +CONFIG_VHOST_VSOCK=m # CONFIG_VHOST_NET is not set # CONFIG_VHOST_SCSI is not set # CONFIG_VHOST_VSOCK is not set ``` -------------------------------- ### Debugging WebRTC Video Issues in Android Emulator Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This snippet provides a command to check logs for the 'pulse', 'video', or 'version' information to help diagnose WebRTC video streaming problems in the Android emulator. It's useful for identifying issues with the video bridge or stream connections. ```bash docker logs docker_emulator_1 | egrep "pulse:|video:|version:" ``` -------------------------------- ### Connect to Emulator via ADB Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Command to connect the local ADB client to the running emulator container. Assumes the emulator is accessible at 'localhost' on port 5555. ```bash $ adb connect localhost:5555 ``` -------------------------------- ### Resolve Docker PermissionError in Python Script Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This Python traceback indicates a 'Permission denied' error when interacting with the Docker API, typically caused by insufficient permissions. The solution involves enabling sudoless Docker access by following the official Docker documentation. ```python Traceback (most recent call last): File "/tmp/android-emulator-container-scripts/emu/docker_device.py", line 78, in create_container logging.info(api_client.version()) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/docker-4.0.2-py3.5.egg/dn return self._result(self._get(url), json=True) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/docker-4.0.2-py3.5.egg/dr return f(self, *args, **kwargs) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/docker-4.0.2-py3.5.egg/dt return self.get(url, **self._set_request_timeout(kwargs)) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/requests-2.22.0-py3.5.egt return self.request('GET', url, **kwargs) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/requests-2.22.0-py3.5.egt resp = self.send(prep, **send_kwargs) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/requests-2.22.0-py3.5.egd r = adapter.send(request, **kwargs) File "/tmp/android-emulator-container-scripts/venv/lib/python3.5/site-packages/requests-2.22.0-py3.5.egd raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied')) ``` -------------------------------- ### Test Python REST API Server Source: https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD Tests the accessibility and response of the Python REST API server by making a curl request. It checks if the API returns a valid JSON RTCConfiguration object. ```shell export API_SERVER=http://turn_key.provider.org curl -s $API_SERVER/turn/localhost?apiKey=$API_KEY ``` -------------------------------- ### Connect ADB to Emulator Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Connects the Android Debug Bridge (ADB) to a running emulator instance, typically accessed via localhost and a specific port. ```sh adb connect localhost:5555 ``` -------------------------------- ### Check Attached ADB Devices Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Lists all devices currently recognized by the ADB server, used to verify emulator connection. ```sh adb devices ``` -------------------------------- ### Handle Incorrect Zip File Format Exception in Python Script Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This Python exception occurs when a provided zip file does not contain a valid Android system image. The error message clearly indicates that the specified file is not a recognized system image zip file, likely due to incorrect parameters or file corruption. ```python Traceback (most recent call last): File "/tmp/android-emulator-container-scripts/venv/bin/emu-docker", line 11, in load_entry_point('emu-docker', 'console_scripts', 'emu-docker')() File "/tmp/android-emulator-container-scripts/emu/emu_docker.py", line 159, in main args.func(args) File "/tmp/android-emulator-container-scripts/emu/emu_docker.py", line 44, in create_docker_image raise Exception("{} is not a zip file with a system image".format(imgzip)) Exception: emulator-29.2.8.zip is not a zip file with a system image ``` -------------------------------- ### Connect ADB to Emulator in Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/README.md Connects the Android Debug Bridge (ADB) to an emulator running inside a Docker container. Assumes ADB port 5555 is forwarded from the container to the host. ```Shell adb connect localhost:5555 ``` ```Shell $ adb devices List of devices attached: localhost:5555 device ``` -------------------------------- ### Force Remove Docker Container Source: https://github.com/google/android-emulator-container-scripts/blob/master/TROUBLESHOOTING.md This command is used to forcefully remove a Docker container that may be in a corrupted state, often necessary when an emulator crashes or terminates unexpectedly and the container cannot be restarted. ```sh docker rm -f CONTAINER_ID ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.