Created
April 23, 2026 19:52
-
-
Save benigumocom/4202ac5728ceada4cd483543fff61360 to your computer and use it in GitHub Desktop.
Agent tools and resources | Android Studio | Android Developers https://developer.android.com/tools/agents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Exit immediately if a command exits with a non-zero status | |
| set -e | |
| # === Configuration === | |
| BINARY_NAME="android" | |
| INSTALL_DIR="/usr/local/bin" | |
| OS="$(uname -s)" | |
| ARCH="$(uname -m)" | |
| if [[ "$OS" == "Linux" ]]; then | |
| URL_OS="linux_x86_64" | |
| elif [[ "$OS" == "Darwin" ]]; then | |
| URL_OS="darwin_arm64" | |
| else | |
| echo "Error: Unsupported OS $OS" | |
| exit 1 | |
| fi | |
| DOWNLOAD_URL="https://dl.google.com/android/cli/latest/${URL_OS}/${BINARY_NAME}" | |
| # 1. Check if curl is installed | |
| if ! command -v curl &> /dev/null; then | |
| echo "Error: curl is required to install or upgrade this software." | |
| exit 1 | |
| fi | |
| echo "Installing $BINARY_NAME..." | |
| # 4. Check permissions and set up sudo if necessary | |
| SUDO="" | |
| if [[ ! -w "$INSTALL_DIR" ]]; then | |
| echo "Administrator privileges are required to install to $INSTALL_DIR." | |
| echo "You may be prompted for your system password." | |
| SUDO="sudo" | |
| fi | |
| # 5. Download the binary | |
| TMP_FILE=$(mktemp) | |
| echo "Downloading..." | |
| curl -fsSL "$DOWNLOAD_URL" -o "$TMP_FILE" | |
| # 6. Move to the system path and make executable | |
| echo "Installing to $INSTALL_DIR..." | |
| $SUDO mv "$TMP_FILE" "${INSTALL_DIR}/${BINARY_NAME}" | |
| $SUDO chmod +x "${INSTALL_DIR}/${BINARY_NAME}" | |
| # Force first download | |
| ANDROID_CLI_FRESH_INSTALL=1 ${INSTALL_DIR}/${BINARY_NAME} | |
| echo "----------------------------------------" | |
| echo "✅ Success! $BINARY_NAME is ready to use." | |
| echo "----------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment