mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.48k stars 251 forks source link

[v1.33.0] Unable to launch app for Android TV #1502

Open yusufyildirim opened 9 months ago

yusufyildirim commented 9 months ago

Describe the bug Maestro is unable to launch Android applications if they don't have CATEGORY_LAUNCHER for their activity in AndroidManifest. Android TV specific applications typically have CATEGORY_LEANBACK_LAUNCHER instead and Maestro is not looking for that.

CLI throws an error like this when it fails: Unable to launch app com.your.app: UNKNOWN

To Reproduce

  1. Setup an Android TV sample app.
  2. Start an Android TV emulator
  3. Run maestro test your_test_file.yaml
  4. See the error at your terminal

Expected behavior App should launch on the Android TV emulator

Environment information (please complete the following information):

yusufyildirim commented 9 months ago

I dug into the problem yesterday and found that this line is the issue here: https://github.com/mobile-dev-inc/maestro/blob/main/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt#L104

I'll create a PR but not sure what the correct approach should be.

The easiest solution seems to looking for getLeanbackLaunchIntentForPackage if getLaunchIntentForPackage returns null as a fallback option but it's a bit problematic. I can technically have two different intents one with CATEGORY_LAUNCHER and the other with CATEGORY_LEANBACK_LAUNCHER and Maestro would always launch the one with CATEGORY_LAUNCHER in this case. This makes me lean towards expecting a flag or argument from the user via CLI or anything of that sort.

Looking for your ideas here, thanks!