question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Appium Android driver.startActivity() is adding -W to the adb command even if appWaitForLaunch is set to false

See original GitHub issue

The problem

After setting appWaitForLaunch to false, when I try to launch activity by calling driver.startActivity() method, it call gets stuck and eventually times out.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.21.0
  • Last Appium version that did not exhibit the issue (if applicable): None
  • Desktop OS/version used to run Appium: Mac OS Mojave
  • Node.js version (unless using Appium.app|exe): 12.18.3
  • Npm or Yarn package manager: NPM
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator: Real Device
  • Appium CLI or Appium.app|exe: Both

Details

I am trying to launch a transparent activity that takes some parameters and updates app preferences. This activity stops immediately after it is done with the update. It does not have any UI. When I try to launch the activity, appium call gets stuck and eventually times out. This is because appium android driver adds -W flag to the target ADB command which waits for the activity to launch. In my case, the activity does not have any UI and so does not launch. I have set the appWaitForLaunch to false and noticed that it only works during driver instance creation and app launch as it does not add -W option. But when tried with driver.startActivity(), it did add the -W option.

Link to Appium logs

[W3C (146a80b7)] Calling AppiumDriver.startActivity() with args: ["com.myapp.app","com.myapp.instrumentation.persistence.preferences.PreferencesOverrideActivity","com.myapp.app","com.myapp.home.splash.SplashActivity","","","","--es "overrideData" '[{"pref_name": "MyPreferences","overrides": [{"key": "myKey","value": "myValue"","type": "string"}],"clear": false}]' [AndroidDriver] Starting package 'com.myapp.app' and activity 'com.myapp.instrumentation.persistence.preferences.PreferencesOverrideActivity' [ADB] Running '/Users/user1/Library/Android/sdk/platform-tools/adb -P 5037 -s e15adapa shell am start -W -n com.myapp.app/com.myapp.instrumentation.persistence.preferences.PreferencesOverrideActivity -S --es '"overrideData"' "'[{"pref_name": "MyPreferences","overrides": [{"key": "myKey","value": "myValue","type": "string"}],"clear": false}]'"' [Instrumentation] INSTRUMENTATION_RESULT: shortMsg=Process crashed. [Instrumentation] INSTRUMENTATION_CODE: 0 [Instrumentation] The process has exited with code 0

Code To Reproduce Issue [ Good To Have ]

Try to launch an activity that does not any UI with androidDriver.startActivity() method while appWaitForLaunch is set to false in capabilities. Stackoverflow question has the details: https://stackoverflow.com/questions/68305135/not-able-to-start-activity-using-appium

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Jul 9, 2021

Unfortunately no timelines. Contributions are completely voluntary, so it could be done in a day or in a year, - no guarantees there.

0reactions
mykola-mokhnachcommented, Jul 11, 2021

Unfortunately the startService extension does not support providing of extra intent arguments as of Appium 1.21 I’ve added this feature to appium@beta though: https://github.com/appium/appium-uiautomator2-driver/pull/468

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to start activity using appium - Stack Overflow
Appium by defaults adds -W to the adb command when startActivity is called which waits till ... You need to set "appWaitForLaunch to...
Read more >
Activities Startup Troubleshooting Guide - Appium
By default the driver always waits until appWaitDuration is expired. Setting this capability to false effectively cancels this wait and unblocks the server...
Read more >
Desired Capabilities - Appium
This set of Desired Capabilities expresses the desire for Appium to begin an automation session on an iPhone 7 simulator with iOS 11,...
Read more >
Start Activity - Appium
Start an Android activity by providing package name and activity name ... driver.startActivity(new Activity("com.example", "ActivityName"));.
Read more >
driver.startActivity fails to wait for app to start up, leads to test ...
Hi! I'm trying to build an Appium test suite for an Android application but I ran into a problem with the Android M's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found