Preview your Codemagic APK build: a phone for the CI loop
Your Codemagic build finishes and produces the artifact nobody opens — an APK attached to a build page, downloaded by no one, installed by fewer. Add one post-build step and the same build lands on a cloud phone, with its preview link posted on the pull request. The reviewer clicks, the app is already running, and the feature is either there or it isn't.
Try it with a live device
PreviewAPK is in private beta. Get early access to test your own builds.
The Codemagic preview gap
Codemagic solved the build side of the CI loop — push, and a signed APK appears on every build, for Flutter, React Native, native Android, even Unity. The preview side is still manual. Codemagic's own App Preview CLI proves the demand: it posts a PR comment so reviewers can try the build. But the comment carries QR codes and download links, and the reviewer still has to scan, download, allow unknown sources, and install — on their personal phone, running a build from a branch they didn't write.
This is where reviews quietly die. One developer posted it plainly after sending a beta APK to ten friends: two asked if his phone had been hacked. A reviewer who has to install a file doesn't review — they skim the diff, write "LGTM, probably," and the first real run of the feature happens in staging, or in a user's hand. The QR code is an improvement on "grab the artifact from the build page," but it asks the reviewer to do installation labor before the review even starts.
From build artifact to live phone
Store your PreviewAPK API key as a Codemagic environment variable named PREVIEWAPK_API_KEY, then add a post-build script to your codemagic.yaml:
scripts:
- name: Post live preview
script: |
curl -o previewapk.py https://previewapk.dev/cli/previewapk.py
python3 previewapk.py use "Device 1"
python3 previewapk.py push build/app/outputs/flutter-apk/app-release.apk --run
python3 previewapk.py links
That's the whole integration. The CLI is a single Python file — no SDK, no emulator, nothing to install on the build machine. Pushing to a running device hot-swaps the new build in live; pushing to an idle one attaches it, and --run starts the session. links prints the preview URLs — post one on the pull request, and every reviewer gets the running app instead of the download link.
The build boots on a real cloud Android phone (Android 10–15, Pixel 9 Pro or Galaxy S24) and streams to the browser. The annotated version of this recipe, plus GitLab, Bitrise, and Jenkins variants, lives in the CI recipes.
For agents
Codemagic now ships an MCP server — an agent can start a build with a tool call instead of a YAML edit. PreviewAPK closes the other half of that loop: the same agent can push the artifact with the CLI or REST API, drive the phone (taps, typing), take screenshots, read the UI hierarchy, and check the session log — then report back with evidence instead of a guess.
This is where the live link earns its keep twice. The agent verifies before any human looks: build finishes, agent drives the app, screenshots land on the PR, and the preview link in the comment points at a session that was actually tested. The full agent testing loop — including the MCP server — is documented with examples.
Share the link, not the file
Every PreviewAPK device carries two kinds of link. The permanent preview link never changes — view-only, safe to paste into a PR template, a README, or a Slack channel. The per-session /v/ link streams one specific build and dies with the session, so a PR comment can never silently point at a newer build that quietly replaced it. Both are view-only: driving requires the owner's portal login or an API key, so a link pasted anywhere can't be hijacked.
No reviewer installs anything, which removes the two failure modes of file-based previews: the "is this safe?" hesitation when a phone flags the APK, and the version confusion when three old builds are sitting in someone's downloads folder. Sessions stop automatically after 15 minutes idle, so a build nobody opens doesn't burn a device slot.
Codemagic App Preview vs live streaming
| Codemagic App Preview (QR / download) | PreviewAPK live streaming | |
|---|---|---|
| What the reviewer does | Scan a QR, download the APK, allow unknown sources, install | Click a link — the app is already running |
| Who can review | People with an Android device willing to install | Anyone with a browser — QA, clients, agents |
| Agent verification | No — an agent can't install or drive a downloaded APK | Yes — CLI, REST API, and MCP: push, drive, screenshot, log |
| Link lifetime | Points at the build artifact | Permanent device link, or a /v/ link that dies with the session |
| Cost | Bundled with your Codemagic plan | The script step is free; the cloud phone is $25/month per account, unlimited runs |
The honest framing: if your reviewers happily install every build, App Preview is already fine. If they'd rather just see the app — or if an agent needs to verify before they look — live streaming is the same PR comment with the install step removed.
Keep going
One device per project is the usual shape: every Codemagic build hot-swaps onto it while it's live, or attaches while it's off, and the preview link never changes. The pattern is the same across CI systems — the GitHub Actions guide shows the PR-comment workflow in full — and it plugs into preview deployments for staging builds too. To hand a build to a client or tester manually, share the APK link; the CI docs have every recipe annotated.
FAQ
How do I preview a Codemagic APK build in a browser?
Add a post-build script to your codemagic.yaml: after the build, run the PreviewAPK CLI (one Python file) with your API key stored as a Codemagic environment variable, push the APK artifact with --run, and post the session's share link on the PR. The build boots on a cloud phone and reviewers open the running app in a browser — no install, no QR download. Recipes are in /docs/ci/.
How is this different from Codemagic's App Preview CLI?
App Preview posts a PR comment with QR codes and download links — the reviewer still downloads, installs, and enables unknown sources. A live preview replaces all of that with a link that opens the already-running build. Codemagic's own preview proves reviewers want builds on their PRs; live streaming answers the same need without the install friction.
Can a coding agent trigger the preview and verify the build?
Yes — this is the core of the loop. Codemagic's MCP lets an agent start builds; PreviewAPK's CLI, REST API, and MCP let the same agent push the artifact, drive the phone (taps, typing), take screenshots, read the UI hierarchy, and check session logs — then report back with evidence. The agent testing loop is documented at /ai-agent-android-testing/.
What does a Codemagic preview cost on PreviewAPK?
The build script step is free; the cloud phone it pushes to is $25/month per account with unlimited runs. Most teams keep one device per project — every Codemagic build hot-swaps onto it while it's live, or attaches while it's off, and the preview link never changes.
Which link should I post on the pull request?
Either of two. Your device has a permanent preview link that never changes (view-only) — good for a PR template or README. Or post the session's /v/ link, which streams that exact build and dies with the session, so a PR comment can never silently point at a newer build. Driving always requires the owner's portal login or API key.