{"data":{"slug":"github-google-skills-skills-cloud-developer-device-platform-device-run-80211e550766","title":"Run Native Binaries or Scripts on Remote Android Devices","summary":"Execute non-interactive jobs on remote Android devices using the Developer Device Platform (DDP) with `gcloud beta device-run sessions`, including native Android executables, shell scripts, and Android instrumentation tests.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-developer-device-platform-device-run-80211e550766","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-developer-device-platform-device-run-80211e550766","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-developer-device-platform-device-run-80211e550766.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-developer-device-platform-device-run-80211e550766\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any `gcloud` command, the user must read and follow the instructions in [Usage Attribution](references\/attribution.md). Confirm cost with the user by specifying the project, devices, number of jobs, and timeout, and obtain explicit approval before proceeding.","instructions":"---\nname: developer-device-platform-device-run\ndescription: >-\n  Runs automated, non-interactive jobs on remote Android devices with Developer\n  Device Platform (DDP) Device Run using `gcloud beta device-run sessions`:\n  native Android executables or shell scripts (for example CLI tools, custom\n  runners, test harnesses or benchmarks) and\n  Android instrumentation tests, on one or many devices, then waits for\n  completion and collects per-device outputs and logs. Use when running a\n  binary or test suite on remote devices without an interactive connection.\n  Don't use it for interactive device reservations, adb tunnels or screen\n  streaming (use developer-device-platform-basics), or for local devices.\nmetadata:\n  version: \"1.0.0\"\n  category: CloudInfrastructureAndServices\n---\n\n# Developer Device Platform: Device Run\n\nDevice Run executes a job on remote DDP devices and returns its artifacts (logs,\npulled files) to a Cloud Storage bucket. One session fans out to one job per\nrequested device.\n\n> [!WARNING]\n> Developer Device Platform (DDP) is currently in Preview. The\n> `gcloud beta device-run` commands might change without notice.\n\n## When to use this skill\n\nThe user wants to...                                       | Use\n:--------------------------------------------------------- | :--\nRun a native binary or shell script on remote devices      | This skill (`android-executable`)\nRun an Android instrumentation test APK on remote devices  | This skill (`instrumentation`)\nReserve a device, connect with adb, stream the screen      | `developer-device-platform-basics`\nExtend or cancel an interactive device lease               | `developer-device-platform-basics`\nWork with a device connected over USB                      | Neither (not DDP)\n\nThe setup below is complete; this skill doesn't depend on another skill for\nauthentication, project selection or API enablement.\n\n### Requests this skill does not handle\n\nFor interactive use (reserve a device, adb, screen streaming, leases):\n\n*   **If `developer-device-platform-basics` is installed:** do not submit a\n    Device Run session; switch to `developer-device-platform-basics`, and note\n    that interactive reservations are also billed to the active project.\n*   **If `developer-device-platform-basics` is not installed:** reply in a\n    single message **without calling any tools** (no commands, searches, file\n    reads or scheduling), then stop:\n    1.  Say that Device Run is for non-interactive batch jobs, so you will not\n        submit a Device Run session.\n    2.  Point the user to an interactive Device Streaming reservation with the\n        `developer-device-platform-basics` skill (or\n        https:\/\/docs.cloud.google.com\/device-streaming\/docs\/overview.md.txt),\n        and suggest installing the skill.\n    3.  Warn that an interactive reservation is also billed to the active\n        Google Cloud project.\n\n### Keep answers fast\n\nPrefer this skill and `gcloud beta device-run ... --help` over broad web\nsearches for Device Run syntax. If `gcloud` or the `beta` component is not\ninstalled, fall back to the official documentation at\nhttps:\/\/docs.cloud.google.com\/developer-device-platform\/device-run.md.txt and\nhttps:\/\/docs.cloud.google.com\/sdk\/gcloud\/reference\/beta\/device-run. For dry\nruns, show the commands instead of running them.\n\n## Usage Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read and follow the instructions in\n[Usage Attribution](references\/attribution.md).\n\n## Setup\n\nRun these checks once per environment. Do not assume tools are installed, and\ndo not install or update software without the user's approval.\n\n1.  **gcloud CLI**: Check that gcloud is installed and has Device Run commands:\n\n    ```bash\n    gcloud --version\n    gcloud beta device-run sessions submit android-executable --help >\/dev\/null\n    ```\n\n    If gcloud is missing, point the user to\n    https:\/\/docs.cloud.google.com\/sdk\/docs\/install-sdk.md.txt. If the `beta`\n    component or the Device Run commands are missing, **ask the user** before\n    running `gcloud components install beta` or `gcloud components update`.\n\n2.  **Authentication**: Check the active account. On a Compute Engine or other\n    remote VM, the active account may be the VM's default service account\n    (`...@...iam.gserviceaccount.com`), which often lacks the scopes Device Run\n    and billing calls need (`No service account scopes specified`). If there is\n    no active account, or only such a service account, ask the user to sign in.\n    `--update-adc` also updates Application Default Credentials in the same\n    flow; add `--no-launch-browser` in SSH or remote terminals:\n\n    ```bash\n    gcloud auth list --filter=status:ACTIVE --format=\"value(account)\"\n    gcloud auth login --update-adc\n    ```\n\n3.  **Project**: Use the user's active project, or the one they name. Never\n    hardcode a project, and don't change the active project without asking.\n\n    ```bash\n    export PROJECT_ID=$(gcloud config get project)\n    # Only if the user asks to switch:\n    gcloud config set project PROJECT_ID\n    ```\n\n4.  **Billing**: Device Run is billed to the project. Check that billing is\n    enabled; if it isn't, stop and tell the user.\n\n    ```bash\n    gcloud billing projects describe \"${PROJECT_ID}\" \\\n      --format=\"value(billingEnabled)\"\n    ```\n\n5.  **Enable the Device Run API** (if not already enabled; ask first):\n\n    ```bash\n    gcloud services enable devicerun.googleapis.com --project=\"${PROJECT_ID}\"\n    ```\n\n6.  **IAM roles**: The user needs `roles\/devicerun.admin`,\n    `roles\/serviceusage.serviceUsageConsumer` and `roles\/viewer` on the\n    project. To read inputs from a bucket in another project, grant the DDP\n    service agent `roles\/storage.objectViewer` on that bucket (see\n    https:\/\/docs.cloud.google.com\/developer-device-platform\/device-run\/share-storage.md.txt).\n\n7.  **Bucket**: Sessions store inputs and outputs in Cloud Storage. Without\n    `--bucket-name`, gcloud uses or creates `gs:\/\/${PROJECT_ID}-devicerun`.\n    For project IDs that contain `:`, `.` or `google`, gcloud replaces them\n    (with `-`, `-` and `elgoog`) before adding `-devicerun`; read the actual\n    bucket from the `Result files` URI printed by `submit` or `describe`. A\n    bucket named explicitly with `--bucket-name` MUST already exist. Pass the\n    bucket name only (no `gs:\/\/`, no path). Inputs and outputs under\n    `gs:\/\/<bucket>\/automation\/` are kept until you delete them or a Cloud\n    Storage lifecycle rule expires them, and storage is billed meanwhile.\n\n## Core workflow\n\n1.  **Pick devices.** Users usually name devices the way they are sold (\"Pixel\n    10\", \"Galaxy S22\"), while `--device` needs a catalog ID such as\n    `frankel-36` (codename + Android API level). Resolve names to IDs from the\n    live catalog with\n    [device_selection.md](references\/device_selection.md); never guess an ID\n    from memory. If a device is offered on several Android versions and the\n    user didn't name one, list the versions, recommend one, and let the user\n    pick one, several (one job each) or all; never pick silently. Before\n    submitting, show the user the resolved ID, the device name and the Android\n    version, and call out any other choice you made for them (physical vs\n    virtual, variant).\n\n2.  **Stage inputs.** `--executable`, `--test`, `--target-app` and the source\n    side of `--other-files-to-push` accept `gs:\/\/` paths or local paths. Local\n    files are uploaded automatically into a fresh\n    `automation\/inputs\/<timestamp>\/` folder, so prefer local paths for files\n    that change between runs (scripts, freshly built binaries). Upload large,\n    reused files (models, datasets) to the bucket once and reference them by\n    `gs:\/\/` path.\n\n3.  **Confirm cost.** **Explicit user confirmation required.** Device Run\n    sessions are billed to the active Google Cloud project. Before submitting,\n    tell the user the project (`${PROJECT_ID}`), the devices, the number of\n    jobs, and the timeout, warn that this incurs charges, and STOP until they\n    approve. Include this billing warning in **every** answer that shows a\n    submit command, even when you only explain the steps or the user will run\n    the command themselves.\n\n4.  **Submit.** Pick the submit type:\n\n    *   Native executable or shell script: see\n        [android_executable.md](references\/android_executable.md).\n    *   Instrumentation test APK: see\n        [instrumentation.md](references\/instrumentation.md).\n    *   Same binary with several configurations (different flags, inputs or\n        environment variables) per device: see\n        [multi_config_runs.md](references\/multi_config_runs.md).\n\n5.  **Wait.** For runs longer than a few minutes, submit with `--async` and\n    follow [session_lifecycle.md](references\/session_lifecycle.md).\n\n6.  **Collect results.** Download and map artifacts to devices with\n    [results.md](references\/results.md).\n\n7.  **Report** one row per device: device ID, job folder (`job-NNN`), result,\n    key outputs, and the `gs:\/\/` path of the session folder. Call out failed,\n    timed-out or cancelled jobs explicitly instead of dropping them.\n\n## Rules\n\n*   **Always set the timeout.** `--executable-timeout` (or\n    `--instrumentation-timeout`) defaults to `5m`; the valid range is `1m` to\n    `3h`. Estimate the run time and set it explicitly.\n*   **Arguments are comma-separated.** Each element of `--executable-args`\n    becomes one argument. Rewrite space-separated command lines. If a value\n    contains a comma, use the `^SEP^` prefix (see\n    [android_executable.md](references\/android_executable.md)).\n*   **No shell in the direct call.** With a binary as `--executable` there is no\n    shell: set environment variables with `--executable-env-vars`, not `export`.\n*   **Do not overwrite shared inputs.** DDP fetches inputs when a job starts.\n    Never overwrite a `gs:\/\/` script or binary that a pending session uses; use\n    local paths (auto-uploaded) or a unique `gs:\/\/` path per run.\n*   **Label sessions** with `--labels` (for example `purpose=smoke,build=1234`)\n    so they are easy to find later.\n*   **Poll politely.** Never poll in a tight loop; poll every 30 to 60 seconds\n    and report progress (see\n    [session_lifecycle.md](references\/session_lifecycle.md)).\n*   **Cancel on request.** If the user wants to stop, cancel the session (see\n    [session_lifecycle.md](references\/session_lifecycle.md)) and tell the\n    user it was cancelled.\n*   **Do not use the Device Streaming API** (`devicestreaming.googleapis.com`,\n    `deviceSessions`) to run batch jobs; that is for interactive leases.\n\n## Reference index\n\n*   [device_selection.md](references\/device_selection.md): map device names\n    such as \"Pixel 10\" to catalog IDs, OS versions, physical vs virtual.\n*   [android_executable.md](references\/android_executable.md): flags, direct\n    call, shared libraries, script as executable.\n*   [instrumentation.md](references\/instrumentation.md): APK tests, sharding,\n    test targets.\n*   [session_lifecycle.md](references\/session_lifecycle.md): sync vs async,\n    wait, describe, cancel, status and result types.\n*   [results.md](references\/results.md): bucket layout, job-to-device mapping,\n    logs.\n*   [multi_config_runs.md](references\/multi_config_runs.md): run\n    the same binary with several configurations per device.\n*   [troubleshooting.md](references\/troubleshooting.md): common failures.\n","use_cases":["Run a CLI tool or custom runner on multiple remote Android devices.","Execute a benchmark or test suite on a fleet of devices without an interactive connection."],"limitations":[],"compatibility":[],"setup_tip":"Run these checks once per environment. Do not assume tools are installed, and\ndo not install or update software without the user's approval.\n\n1.  **gcloud CLI**: Check that gcloud is installed and has Device Run commands:\n\n    ```bash\n    gcloud --version\n    gcloud beta device-run sessions submit android-executable --help >\/dev\/null\n    ```\n\n    If gcloud is missing, point the user to\n    https:\/\/docs.cloud.google.com\/sdk\/docs\/install-sdk.md.txt. If the `beta`\n    component or the Device Run commands are missing, **ask the user** before\n    running `gcloud components install beta` or `gcloud components update`.\n\n2.  **Authentication**: Check the active account. On a Compute Engine or other\n    remote VM, the active account may be the VM's default service account\n    (`...@...iam.gserviceaccount.com`), which often lacks the scopes Device Run\n    and billing calls need (`No service account scopes specified`). If there is\n    no active account, or only such a service account, ask the user to sign in.\n    `--update-adc` also updates Application Default Credentials in the same\n    flow; add `--no-launch-browser` in SSH or remote terminals:\n\n    ```bash\n    gcloud auth list --filter=status:ACTIVE --format=\"value(account)\"\n    gcloud auth login --update-adc\n    ```\n\n3.  **Project**: Use the user's active project, or the one they name. Never\n    hardcode a project, and don't change the active project without asking.\n\n    ```bash\n    export PROJECT_ID=$(gcloud config get project)\n    # Only if the user asks to switch:\n    gcloud config set project PROJECT_ID\n    ```\n\n4.  **Billing**: Device Run is billed to the project. Check that billing is\n    enabled; if it isn't, stop and tell the user.\n\n    ```bash\n    gcloud billing projects describe \"${PROJECT_ID}\" \\\n      --format=\"value(billingEnabled)\"\n    ```\n\n5.  **Enable the Device Run API** (if not already enabled; ask first):\n\n    ```bash\n    gcloud services enable devicerun.googleapis.com --project=\"${PROJECT_ID}\"\n    ```\n\n6.  **IAM roles**: The user needs `roles\/devicerun.admin`,\n    `roles\/serviceusage.serviceUsageConsumer` and `roles\/viewer` on the\n    project. To read inputs from a bucket in another project, grant the DDP\n    service agent `roles\/storage.objectViewer` on that bucket (see\n    https:\/\/docs.cloud.google.com\/developer-device-platform\/device-run\/share-storage.md.txt).\n\n7.  **Bucket**: Sessions store inputs and outputs in Cloud Storage. Without\n    `--bucket-name`, gcloud uses or creates `gs:\/\/${PROJECT_ID}-devicerun`.\n    For project IDs that contain `:`, `.` or `google`, gcloud replaces them\n    (with `-`, `-` and `elgoog`) before adding `-devicerun`; read the actual\n    bucket from the `Result files` URI printed by `submit` or `describe`. A\n    bucket named explicitly with `--bucket-name` MUST already exist. Pass the\n    bucket name only (no `gs:\/\/`, no path). Inputs and outputs under\n    `gs:\/\/<bucket>\/automation\/` are kept until you delete them or a Cloud\n    Storage lifecycle rule expires them, and storage is billed meanwhile.","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/developer-device-platform-device-run\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T14:19:10.000000Z","updated_at":"2026-11-17T05:10:29.000000Z","seo_title":"Run Native Binaries on Remote Android Devices","seo_description":"Execute non-interactive jobs on remote Android devices using the Developer Device Platform (DDP) with `gcloud beta device-run sessions`.","seo_keywords":["run android binaries remotely","execute scripts on remote devices","non-interactive device testing","gcloud device-run sessions"]}}