Install, launch and read an app on the emulated Android
Install an APK, launch the app by package, adjust permissions and read the screen and the logs of the emulated Android.
This is the Android path: putting an APK on the emulated device, opening the app, changing runtime permissions and reading what is happening — the accessibility tree and logcat. These are the steps that replace “installing through Android Studio” and “looking at the screen” when the device is inside Elyra.
Prerequisites
- An emulated Android device active for the workspace. See Mobile emulator.
- The APK already built on disk, if you are going to install it.
- The app’s package — and the activity, if it is not the default one.
Steps
-
Install the APK. Point at the file path and the target:
Janela do terminal elyra emulator install ./app-debug.apk --device emulator-5554 --jsonUse
--reinstallto replace an existing install of the same package:Janela do terminal elyra emulator install ./app-debug.apk --reinstall --json -
Launch the app by package, with the activity when it matters:
Janela do terminal elyra emulator launch com.acme.app --activity .MainActivity --json -
Grant or revoke a runtime permission. The order is
grant|revoke, then the package, then the permission:Janela do terminal elyra emulator permissions grant com.acme.app android.permission.CAMERA --jsonelyra emulator permissions revoke com.acme.app android.permission.CAMERA --json -
Reset every runtime grant at once, when you want a clean state.
resettakes neither a package nor a permission:Janela do terminal elyra emulator permissions reset --json -
Read the screen through the accessibility tree.
axdumps the uiautomator tree, which is how you know what is visible without a screenshot:Janela do terminal elyra emulator ax --device emulator-5554 --json -
Capture a log excerpt.
logcatmakes a one-shot dump, with a line limit and per-tag filters:Janela do terminal elyra emulator logcat --lines 200 --device emulator-5554 --jsonelyra emulator logcat --filters "MyTag:D" --filters "*:S" --lines 200 --jsonEach filter is
TAG:PRIORITY, with priority amongV D I W E F Sand*as the wildcard tag.
Result
- The APK stays installed on the emulated device and the app opens by package and activity.
- The state of runtime permissions is under your control through the commands, without going through the Android UI.
- The accessibility tree and the log lines say what the app published and recorded.
Limits
- These commands are Android-only. On an iOS Simulator they are refused with
emulator_unsupported. On iOS,installandlaunchare up to Apple’s tooling, outside Elyra. - An untrusted APK changes the device. Installing is running third-party code on the device: install only what you built or trust, and prefer a throwaway AVD for it.
resetremoves every runtime grant you gave — not only the last one. It is the way back to the initial state and also the way to break an app that depended on them.- The accessibility tree and the logs can contain personal data or tokens. Redact before sharing: nothing here was written to become a public attachment.
- Read the result field, not just the absence of an error.
installanswersinstalled,launchanswerslaunchedandpermissionsanswersapplied; the false variant carries the reason. - The permissions order is the common trap: swapping package and permission is refused, and the refusal does not say which of the two is out of place.
- There is no verb to uninstall an app in this family.
execis a raw passthrough, runs in the device shell and returns only stdout — and it can change the simulator’s state. - There is no screenshot and no copying of files off the device here.
Recovery and safe cleanup
- The install failed — re-read the reason in the reply; confirm the APK path exists on the execution host and that the target is an Android device.
- The app did not open — check the package and the activity; without
--activity, the package must resolve the default activity. - The permission was refused — confirm the
grant|revokeorder, the package and the full permission name (android.permission.<NAME>). - Undoing a grant —
permissions revokefor a specific permission;permissions resetfor all of them. - Stopping the helper —
elyra emulator killto free the session leaving the device on, orelyra emulator shutdownto stop it and power the device off. See Emulator commands.