# Bring your build: preview your APK on a cloud phone

Mobilebox doesn't build your app: you build it where you already do (EAS, GitHub Actions, Gradle on your machine), and give us the APK's URL. One call puts it on a live phone and returns a link you can embed or open.

[Embed guide](/docs/embed) · [Expo apps](/docs/expo) · [API reference](/docs/reference#embed-a-phone-in-your-app) · [Errors and recovery](/docs/errors)

## The one call

Any URL that downloads the APK without a login works: `apk_url` takes an `.apk`, or a split bundle (`.apks`, `.xapk`) with its base APK, up to 2 GB. Allow your page's origin once ([embed guide, step 1](/docs/embed#1-allow-your-origins-once)), then:

```bash
curl -X POST https://mobilebox.dev/v1/previews \
  -H "Authorization: Bearer $MOBILESANDBOX_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: user_42-build_17" \
  -d '{"apk_url": "https://github.com/mobilebox-dev/mobilebox/releases/download/example-apks/mobilebox-example-release.apk",
       "end_user": "user_42", "origin": "https://app.example.com", "interactive": true}'
```

```json
{ "phone_id": "ph_…", "embed_url": "https://mobilebox.dev/embed?t=e1.ph_…", "expires_at": "…",
  "package": "com.anonymous.example", "reused": false, "origin": "https://app.example.com", "interactive": true }
```

That URL is a real build you can try: a blank Expo app built by [this GitHub Actions workflow](https://github.com/mobilebox-dev/mobilebox/blob/research/builds/.github/workflows/example-apks.yml), 21 MB. On 26 November 2026 the call above answered in 25 s on a new phone (start, download, install, app on screen), with the app's "Mobilebox: bring your build" screen showing in the embed. The phones run arm64 and 32-bit ARM code, not x86: build `arm64-v8a`.

## From EAS Build

EAS gives a store build (`.aab`) by default. Add a profile that makes an APK, in `eas.json`:

```json
{ "build": { "preview": { "distribution": "internal", "android": { "buildType": "apk" } } } }
```

Build and take the artifact URL from the JSON answer:

```bash
APK_URL=$(eas build -p android --profile preview --non-interactive --wait --json | jq -r '.[0].artifacts.buildUrl')
```

`buildUrl` is an `https://expo.dev/artifacts/eas/….apk` link that downloads without a login: send it as `apk_url`. In an EAS webhook or workflow, the same field is `artifacts.buildUrl`.

## From GitHub Actions or Gradle

Build the APK (the workflow linked above does this for an Expo app; a plain Android app starts at the Gradle line):

```bash
npx expo prebuild -p android --no-install          # Expo only
cd android && ./gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a
# → android/app/build/outputs/apk/release/app-release.apk
```

Then give it a URL that needs no login. An Actions *artifact* won't do: its download needs a GitHub token and comes zipped. Use one of these:

- **A release asset:** `gh release upload previews app-release.apk --clobber` gives `https://github.com/<owner>/<repo>/releases/download/previews/app-release.apk` (public repositories).
- **Your storage, presigned:** upload to S3, R2 or GCS and send a presigned GET URL valid for at least 15 minutes, for example `aws s3 presign s3://builds/pr-17.apk --expires-in 3600`. Works for private code, and the link expires by itself.

A release APK needs a signing key; `assembleRelease` in a fresh Expo prebuild signs with the debug key, which is fine for previews.

## Expo dev-client builds: change JavaScript without a new APK

Build a development build once (`eas build --profile development -p android`, or `assembleDebug` with `expo-dev-client` installed). It loads its JavaScript from your Metro server, so after that a JS-only change needs no build at all.

1. **Put the dev client on the user's phone:** `POST /v1/previews` with its `apk_url`, as above. Try ours: `https://github.com/mobilebox-dev/mobilebox/releases/download/example-apks/mobilebox-example-devclient.apk` (scheme `mobileboxexample`).
2. **Start Metro where the phone can reach it:** `npx expo start --dev-client --tunnel` prints an `https://….exp.direct` URL.
3. **Open the build at your Metro server** with the app's own scheme:

```bash
curl -X POST https://mobilebox.dev/v1/phones/$PHONE_ID/actions \
  -H "Authorization: Bearer $MOBILESANDBOX_API_KEY" -H "Content-Type: application/json" \
  -d '{"actions": [{"type": "open_url", "url": "mobileboxexample://expo-development-client/?url=https%3A%2F%2Fabc1234-anonymous-8081.exp.direct"}]}'
```

The first time, the dev client shows its developer menu over the app: tap **Close** (`{"type": "tap", "target": {"text": "Close"}}`). From then on, save a JS file and the app reloads from Metro; to reload by hand, send the same `open_url` again. A new preview call for the same `end_user` and the same APK reuses the phone with the app already on it (6 s in our test).

On 26 November 2026 we previewed the example dev client on prod, pointed it at a Metro server, changed the text in `App.js` and reopened it: the phone showed the new text, with no new APK.

## When it fails

A build that doesn't go on answers `install_failed`, one that doesn't come up answers `open_failed`. Both carry `details.phone_id`, so you fix the build and call again on the same phone, and `details.cause` says why:

| `details.cause` | Means | Do |
|---|---|---|
| `download_failed` | The URL didn't return the file: a login page, an expired presigned link, a 404 | Open the URL in a private window; send one that downloads by itself |
| `invalid_apk` | Not an APK: often a zipped Actions artifact or an `.aab` | Send the `.apk`, or a split bundle with its base APK |
| `unsupported_abi` | x86-only native code | Build `arm64-v8a` |
| `signature_mismatch`, `version_downgrade` | The phone has the app from another key, or a newer version | Uninstall it first (`DELETE /v1/phones/{id}/apps/{package}`), or raise `versionCode` |
| (with `open_failed`) | Installed, but the app crashed or didn't draw | `GET /v1/phones/{id}/apps/{package}/logs` has its crash and log lines |

All codes: [Errors and recovery](/docs/errors).
