build_and_run
Build an Android project with Gradle, install the resulting APK on a connected device, and launch the specified app package in one command.
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 but in a single call. If several APKs exist under build/outputs (multi-flavor projects, leftover androidTest APKs), the newest non-test one is installed — the artifact the build just produced.
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. |