Install an APK
android_installInstalls an APK on an Android device, replacing the existing app. Accepts an explicit APK path or uses the latest Gradle build output, with options for module, variant, device, and permission grants.
Instructions
Install an APK onto a device, replacing any existing copy.
Args:
apk_path (string, optional): absolute path to the APK. Omit to use the last build output of project_path.
project_path (string, optional): Gradle root, used to locate the APK when apk_path is omitted
module (string): module that produced the APK (default: 'app')
variant ('debug' | 'release'): which build output to install (default: 'debug')
serial (string, optional): target device
grant_permissions (boolean): grant all runtime permissions at install time (default: false)
Returns: { "installed": boolean, "apkPath": string, "serial": string }
Examples:
Use when: an APK was built earlier and you want it on the device -> project_path=...
Use when: installing a downloaded APK -> apk_path=...
Don't use when: you also need to compile first (use android_build with install=true)
Error Handling:
INSTALL_FAILED_UPDATE_INCOMPATIBLE: the installed copy was signed with a different key; uninstall it first
INSTALL_FAILED_VERSION_DOWNGRADE: the device has a newer versionCode; uninstall or bump the version
INSTALL_FAILED_INSUFFICIENT_STORAGE: free space on the device
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| module | No | Gradle module that produces the APK. Almost always 'app'. | app |
| serial | No | Device serial from android_list_devices. Optional when exactly one device is connected; required when several are. | |
| variant | No | Build variant. 'release' requires signing config to be set up in the project. | debug |
| apk_path | No | Absolute path to an APK file. | |
| project_path | No | Gradle root, used to find the APK when apk_path is omitted. | |
| grant_permissions | No | Grant all runtime permissions listed in the manifest (adb install -g). |