appium: Android driver fails before emulator is booted
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.
About this issue
- Original URL
 - State: closed
 - Created 2 years ago
 - Comments: 20
 
@mykola-mokhnach
Im getting the same error, when running test against emulator using appium 2 and latest UIautomator plugin
I’m afraid the timeout there is hardcoded. Although I don’t see a reason it could not be increased
@StephanB75 Try uia2 driver v. 2.4.5
I’ve changed the boot detection logic - lets see if it helps
Hey @StephanB75 I did have appium settings from previous runs. I have deleted it and we are back to first error again https://gist.github.com/jmalczak/efa9e97f3fecb5e93afc185a5873242a
was there an appium settings app from the previous runs on the device ?
Try to delete it so that appium can reinstall it. That helped me in the past when switching versions.