Disclosure up front: I work in growth marketing at DuoPlus, a cloud phone service. I'm using it in this walkthrough because it's what our team runs, but the adb part works the same against any remote Android device you can reach over adb.

I'm not a full-time mobile engineer. I'm the person who kept noticing, every other Monday, that our demo build had quietly broken on one Android version over the weekend. So I wrote a small nightly smoke test. It's not clever. It installs the latest build on a few cloud phones, launches it, checks that the main activity actually comes up, grabs a screenshot and logcat, and posts a pass/fail line.

This post is the boring, working version of that script.

What you need

  • A CI runner or any Linux box with a cron job.
  • adb from Android platform-tools.
  • A few cloud phones. In our case: DuoPlus phones on Android 10, 11, 12 and 15, each one a separate device environment that keeps its data between runs.
  • Your app's APK from the nightly build.
  • An API key for whatever cloud phone provider you use.

I won't list DuoPlus API endpoint names here, because I'd rather you read the current docs than copy something from a blog post that might drift. The docs are linked from duoplus.net. In general terms, the API steps you need are: power a phone on, get its adb connection info, and power it off afterwards. Most providers expose something along those lines.

Step 1: wake the phones and get adb addresses

I keep a tiny config file with the device IDs:

# devices.txt — one cloud phone ID per line, one per Android version phone-a10 phone-a11 phone-a12 phone-a15 

The wrapper script calls the provider's API to start each phone and fetch its adb host:port. I hid that behind two shell functions, so swapping providers only touches them:

start_phone() { # call your provider's "power on" API for $1 ./provider-cli start "$1"; } adb_address() { # call your provider's API, print host:port for $1 ./provider-cli adb-address "$1"; } stop_phone() { ./provider-cli stop "$1"; } 

provider-cli here is a small script in our repo that wraps HTTP calls with curl. Yours will look different.

Since billing is per minute, step 1 and the final "stop" step matter more than you'd think. A phone left on overnight is the most expensive bug in this whole setup.

Step 2: connect and wait for boot

ADDR=$(adb_address "$PHONE") adb connect "$ADDR" adb -s "$ADDR" wait-for-device # wait until Android reports boot completed until [ "$(adb -s "$ADDR" shell getprop sys.boot_completed | tr -d '\r')" = "1" ]; do sleep 2 done echo "$PHONE: $(adb -s "$ADDR" shell getprop ro.build.version.release | tr -d '\r')" 

That last line prints the Android version. It's in the log on purpose: when something fails, the first question is always "on which version?".

Step 3: install the nightly build

adb -s "$ADDR" install -r -d app-nightly.apk 

-r replaces the existing install and keeps data, -d allows a version downgrade if someone rebuilt an older tag. If you want a clean start each night, uninstall first:

adb -s "$ADDR" uninstall com.example.myapp || true adb -s "$ADDR" install app-nightly.apk 

We actually do both, on different phones. Two phones keep data (to catch migration bugs), two start clean (to catch first-run bugs). Because each cloud phone keeps its own state long term, the "keeps data" phones really do look like a user who has had the app for a month.

Step 4: launch and check it actually came up

adb -s "$ADDR" logcat -c adb -s "$ADDR" shell am start -W -n com.example.myapp/.MainActivity sleep 8 # is our process alive? PID=$(adb -s "$ADDR" shell pidof com.example.myapp | tr -d '\r') # is our activity on top? TOP=$(adb -s "$ADDR" shell dumpsys activity activities | grep -m1 -E "topResumedActivity|mResumedActivity") 

am start -W waits for the launch and prints timing info, which is handy to keep in the log. The pass condition is simple: PID is non-empty and TOP contains our package name.

Then, pass or fail, collect evidence:

adb -s "$ADDR" exec-out screencap -p > "out/$PHONE.png" adb -s "$ADDR" logcat -d -v time > "out/$PHONE.log" grep -E "FATAL EXCEPTION|ANR in com.example.myapp" "out/$PHONE.log" && FAIL=1 

Step 5: one tap deeper (optional)

A launch-only test catches crashes on startup. That's most of what we wanted. If you want one more step, a single tap on a known coordinate or a deep link works:

adb -s "$ADDR" shell am start -a android.intent.action.VIEW -d "myapp://settings" adb -s "$ADDR" shell input keyevent KEYCODE_BACK 

I'd stop there. Once you start scripting full flows with input tap, move to Espresso or UI Automator instead; coordinates break with every layout change.

Step 6: clean up, always

adb disconnect "$ADDR" stop_phone "$PHONE" 

Put this in a trap ... EXIT so it runs even when the script dies halfway. I learned that one the hard way.

Putting it together

The loop is just:

while read -r PHONE; do start_phone "$PHONE" run_smoke "$PHONE" # steps 2–5 stop_phone "$PHONE" done < devices.txt 

We run it at 02:00 Singapore time, after the nightly build finishes. The output is four lines in a chat channel, something like A15 PASS 1.9s or A11 FAIL – see A11.log, plus the screenshots in the CI artifacts.

Things I'd tell myself earlier

  • Log the Android version on every run. It saves an argument later.
  • Keep one phone untouched by humans. If teammates also use the phones manually (ours do, root included, for debugging), give the nightly job its own devices. Handing a phone over to a colleague is a one-click thing in DuoPlus, which also makes it too easy to "borrow" the test phone.
  • If your app has an OTP signup flow, DuoPlus cloud numbers can receive verification SMS for testing your own app's flow. I keep that out of the nightly job; it's a separate, manual weekly check.
  • Don't over-build it. Ours is one short bash file. It has already caught startup crashes that only showed up on Android 15, which is exactly the kind of thing nobody checks by hand on a Friday.

If you build something similar on another provider, I'd love to see how you handled the boot wait. Mine still feels a bit crude.