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.

Android driver fails before emulator is booted

See original GitHub issue

The problem

When I use avd capability to start emulator, android driver fails even before emulator is booted up.

adb -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy'' exited with code 20'; Command output: cmd: Can't find service: settings
cmd: Can't find service: settings
cmd: Can't find service: settings

Environment

  • Appium version (or git revision) that exhibits the issue: 1.22.3
  • Desktop OS/version used to run Appium: MacOs 12.4
  • Node.js version (unless using Appium.app|exe): 18.5
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator: simulator

Details

Used capabilities

            appiumOptions.AddAdditionalAppiumOption(MobileCapabilityType.PlatformName, "Android");
            appiumOptions.AddAdditionalAppiumOption("appPackage", "appPackage");
            appiumOptions.AddAdditionalAppiumOption("appActivity", "SplashScreen");
            appiumOptions.AddAdditionalAppiumOption("avd", "Pixel_2_API_31");
            appiumOptions.AddAdditionalAppiumOption("avdArgs", "-no-snapshot-load");
            appiumOptions.AddAdditionalAppiumOption("androidInstallTimeout", 120000); 
            appiumOptions.AddAdditionalAppiumOption("newCommandTimeout", 120); 
            appiumOptions.AddAdditionalAppiumOption("acceptInsecureCerts", true); 
            appiumOptions.AddAdditionalAppiumOption("appWaitDuration", 60000);
            appiumOptions.AddAdditionalAppiumOption("avdLaunchTimeout", 180000); 
            appiumOptions.AddAdditionalAppiumOption("avdReadyTimeout", 180000); 

            var driver = new AndroidDriver(ap, appiumOptions); // initialize Android 

When AndroidDriver is instantiated, it starts android emulator, emulator starts booting, shows google logo, appium fails with error:

adb -P 5037 -s emulator-5554 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy'' exited with code 20'; Command output: cmd: Can't find service: settings
cmd: Can't find service: settings
cmd: Can't find service: settings

10 seconds later emulator is booted up to home screen properly. When I start emulator manually before running appium everything works just fine.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19

github_iconTop GitHub Comments

2reactions
mykola-mokhnachcommented, Jul 18, 2022

I’m afraid the timeout there is hardcoded. Although I don’t see a reason it could not be increased

1reaction
mykola-mokhnachcommented, Jul 18, 2022

@StephanB75 Try uia2 driver v. 2.4.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Emulator in Android Studio doesn't start - Stack Overflow
In my case the android hangs at start up. I solved by wiping user data and forcing a cold boot, using Android Virtual...
Read more >
Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
Android Emulator Troubleshooting - Xamarin - Microsoft Learn
This article explains how to diagnose and work around problems that may occur when using the Android Emulator.
Read more >
ADB shows error 'no devices/emulators found'
I have recently tried using ADB/fastboot to install the community build. I am certain I have installed the correct ADB/fastboot drivers and also...
Read more >
error failed to launch emulator. reason: emulator exited before ...
check in the AVD that a particular Android OS is selected and installed for a virtual device you use (in my case it...
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