appium: AppiumDriver fails to install io.appium.settings on Android 12 - API 31 when booting the emultator for the first time.

The problem

AppiumDriver fails to install io.appium.settings on Android 12 - API 31 when booting the emulator for the first time.

Environment

  • Appium version (or git revision) that exhibits the issue: 2.0.0-beta.40
  • Last Appium version that did not exhibit the issue (if applicable): -
  • Desktop OS/version used to run Appium: Ubuntu 20.10
  • Node.js version (unless using Appium.app|exe): v16.14.2
  • Npm or Yarn package manager: 8.13.2
  • Mobile platform/version under test: Android 12 (API 31)
  • Real device or emulator/simulator: emultator (Pixel_5_API_31)
  • Appium CLI or Appium.app|exe: -
  • Espresso Driver: 2.8.1

Details

Appium/Espresso driver fails to install io.appium.settings when using an emulator with Android 12 (API 31) when booting for the first time (emulator just created or data wiped beforehand). If I close the emulator and run the test again everything works fine. This does NOT happen when using Android 11 (API 30) or Android 10 (API 29).

I think this might be related to https://github.com/appium/appium/issues/17200 - I had the same error when using espresso 2.7.1 with API 31, after upgrading espresso to 2.8.1 the error changed. And because this happens only when booting for the first time - I watched the emulator with log in real time and it seems it tries to install the io.appium.settings before Android has finished loading.

I tried using the timeout options, but it had no effect.

  .setAvdLaunchTimeout(Duration.ofMinutes(10))
  .setAvdReadyTimeout(Duration.ofMinutes(10))
  .setAndroidInstallTimeout(Duration.ofMinutes(10))
  .setAdbExecTimeout(Duration.ofMinutes(10))

Link to Appium logs

API 29 log API 30 log API 31 log - first boot API 31 logcat - first boot API 31 log - second run

Code To Reproduce Issue [ Good To Have ]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (1 by maintainers)

Most upvoted comments

@mykola-mokhnach Hi, I had the same issue recently and I believe is related to some services not being ready in the startup.

For example, I used an emulator with the image system-images;android-30;google_apis;x86_64, and worked fine, but when using the image system-images;android-30;google_apis_playstore;x86_64 (with play store) I had the same error when installing the settings. One difference with the play store version is that it asks to update services, for example, google maps, chrome, etc. Just to mention that using the 1.x version works but the 2.x version fails.

Describe the stcktrace you get in adb logs and the steps to reproduce it. Perhaps, they could advice some more reliable way of emulator startup detection if such behaviour is expected (which I have doubts).

The update has been published

The NullPointerException you get with adb anyway does not relect anything good. In appium-adb code we try to detect emulator startup by checking the list of running services. And since Android does not start all services at once it might be some of them are running while other are still being loaded. In the PR above I have added one more service to the list of services we verify there that I assume might be necessary for this adb install command to work in this situation. The actual outcome needs to be tested anyway.