Skip to content

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.

View Markdown

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

  1. Install the APK. Point at the file path and the target:

    Janela do terminal
    elyra emulator install ./app-debug.apk --device emulator-5554 --json

    Use --reinstall to replace an existing install of the same package:

    Janela do terminal
    elyra emulator install ./app-debug.apk --reinstall --json
  2. Launch the app by package, with the activity when it matters:

    Janela do terminal
    elyra emulator launch com.acme.app --activity .MainActivity --json
  3. 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 --json
    elyra emulator permissions revoke com.acme.app android.permission.CAMERA --json
  4. Reset every runtime grant at once, when you want a clean state. reset takes neither a package nor a permission:

    Janela do terminal
    elyra emulator permissions reset --json
  5. Read the screen through the accessibility tree. ax dumps the uiautomator tree, which is how you know what is visible without a screenshot:

    Janela do terminal
    elyra emulator ax --device emulator-5554 --json
  6. Capture a log excerpt. logcat makes a one-shot dump, with a line limit and per-tag filters:

    Janela do terminal
    elyra emulator logcat --lines 200 --device emulator-5554 --json
    elyra emulator logcat --filters "MyTag:D" --filters "*:S" --lines 200 --json

    Each filter is TAG:PRIORITY, with priority among V D I W E F S and * 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, install and launch are 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.
  • reset removes 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. install answers installed, launch answers launched and permissions answers applied; 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. exec is 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|revoke order, the package and the full permission name (android.permission.<NAME>).
  • Undoing a grant — permissions revoke for a specific permission; permissions reset for all of them.
  • Stopping the helper — elyra emulator kill to free the session leaving the device on, or elyra emulator shutdown to stop it and power the device off. See Emulator commands.

Next steps