Skip to content

Device Interaction

Build, deploy, and interact with your app on a connected Android device or emulator via ADB.


Check that a device is connected, the app is installed, and ADB is reachable — before issuing any other device command.

What to ask your AI:

  • “is the app running on device?”
  • “check device status before we start”
  • “do we have a connected device?”

Parameters

NameTypeRequiredDefaultDescription
project_pathstringYesPath to the target project (used to resolve the app package)
device_idstringNoauto-selectADB device serial; auto-selected when only one device is connected

Tips

  • Run this at the start of any device-heavy session — it surfaces missing ADB authorisation, multiple devices without an explicit device_id, or a stale install before you attempt a build.

Build the app and install it on the target device in one step.

What to ask your AI:

  • “build and install the app”
  • “deploy the staging flavour”
  • “rebuild and push to device”

Parameters

NameTypeRequiredDefaultDescription
project_pathstringYesPath to the root of the target project
modulestringNo:appGradle module to build (e.g. :app, :sample)
variantstringNodebugBuild variant (e.g. debug, release, staging)
device_idstringNoauto-selectADB device serial
flavorstringNoProduct flavor combined with variant (e.g. freefreeDebug)

Tips

  • The tool streams Gradle output so the AI can report compile errors immediately.
  • After a successful install the app is launched automatically — follow up with cp_take_device_screenshot to confirm the splash screen rendered.

Perform a gesture, text input, navigation action, or launch command on the device. A screenshot is captured automatically after every action.

What to ask your AI:

  • “tap the Login button”
  • “type test@example.com into the email field”
  • “scroll down to the bottom”
  • “go back”
  • “swipe left to dismiss”

Parameters

NameTypeRequiredDefaultDescription
actionenumYesOne of: tap_element, tap, long_press, swipe, scroll, text, back, home, enter, launch, wait_for
element_textstringNoAccessibility text of the element to target (for tap_element)
xintNoScreen X coordinate in pixels (for coordinate-based actions)
yintNoScreen Y coordinate in pixels
end_xintNoEnd X coordinate for swipe
end_yintNoEnd Y coordinate for swipe
directionstringNoOne of: up, down, left, right (for scroll)
duration_msintNoGesture duration in milliseconds
timeout_msintNo5000Maximum wait time in ms for wait_for action
textstringNoText to input (for text action)
activitystringNoFully-qualified Activity class to launch (for launch action)
device_idstringNoauto-selectADB device serial

Tips

  • A screenshot is taken automatically after every action — you do not need to call cp_take_device_screenshot separately.
  • Prefer tap_element with element_text over coordinate-based tap — it is resolution-independent and survives layout changes.
  • Use wait_for with element_text to pause until a loading state resolves before issuing the next action.

Capture the current screen and return it to the AI.

What to ask your AI:

  • “take a screenshot”
  • “what’s on screen right now?”
  • “capture the current state”

Parameters

NameTypeRequiredDefaultDescription
device_idstringNoauto-selectADB device serial

Tips

  • Uses the two-step file-pull approach (adb shell screencapadb pull) to avoid binary stream corruption on macOS — do not bypass this with adb exec-out.
  • Useful as a quick sanity check after navigating to a new screen before asking the AI to interact with elements.

Compare the currently-installed APK version against the project’s build output to determine whether a re-deploy is needed.

What to ask your AI:

  • “is the installed version up to date?”
  • “has anything changed since the last install?”

Parameters

NameTypeRequiredDefaultDescription
project_pathstringYesPath to the target project
modulestringNo:appGradle module to check
device_idstringNoauto-selectADB device serial
packagestringNoauto-detectApp package name; auto-detected from AndroidManifest.xml

Tips

  • The comparison uses versionCode and the APK last-modified timestamp — no full Gradle sync needed.
  • Pair with cp_build_and_deploy to ensure the AI always tests the latest code.