Build and run
build_and_runBuilds an Android project with Gradle (default assembleDebug), installs the generated APK on the device, and launches the specified package in one blocking call.
Instructions
One-shot build → install → launch: runs Gradle (default task assembleDebug) in project_dir, installs the resulting APK on the device, and launches package. Equivalent to gradle_build + install_app + launch_app in a single call, and it blocks for the whole build. A failed build returns the same summary and full-log path as gradle_build. If several APKs exist under build/outputs (multi-flavor projects, leftover androidTest APKs), the newest non-test one is installed.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"package": "<package>"
},
"name": "build_and_run"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Extra arguments passed to Gradle (e.g. --stacktrace, -Pflavor=free). | |
| task | No | Gradle task to run. Defaults to assembleDebug. | |
| serial | No | Target device serial (adb -s). Optional when exactly one device is attached. | |
| package | Yes | Application package name to install and launch, e.g. com.example.app. | |
| project_dir | No | Path to the Android project root containing the Gradle wrapper (gradlew). Optional if session_set_defaults has pinned a project_dir for this session. |