If emulated device is not running, Appium always failed with "Error type 3..."
If emulated device is not running, Appium always failed with Error: Cannot start the 'io.appium.settings' application. Consider checking the driver's troubleshooting documentation. Original error: Error executing adbExec. Original error: 'Command '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start-activity -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' exited with code 1'; Command output: Error type 3 Error: Activity class {io.appium.settings/io.appium.settings.Settings} does not exist.
If the device has already been running, there is no error.
Environment
- Ubuntu 22.04
- Appium 2.13.1
- uiautomator2 driver 3.9.5
- Android emulator 35.2.10
- Android 15, image
system-images;android-35;google_apis;x86_64
Appium Server logs
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd reboot_readiness check-subsystems-state --list-blocking'
[2358fa3b][ADB] Waiting for emulator startup. Intermediate state: cmd: Can't find service: reboot_readiness
[2358fa3b][ADB] [AVD OUTPUT] DEBUG | _hwFingerprint_connect: connect finger print listen is called
[2358fa3b][ADB] [AVD OUTPUT] DEBUG | got message from guest system fingerprint HAL
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd reboot_readiness check-subsystems-state --list-blocking'
[2358fa3b][AndroidUiautomator2Driver@1a72] Using device: emulator-5554
[2358fa3b][ADB] Using 'adb' from '/opt/android-sdk/platform-tools/adb'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 start-server'
[2358fa3b][ADB] Setting device id to emulator-5554
[2358fa3b][AndroidUiautomator2Driver@1a72] We're going to run a Chrome-based session
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[2358fa3b][ADB] Current device property 'ro.build.version.sdk': 35
[2358fa3b][ADB] Getting device platform version
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[2358fa3b][ADB] Current device property 'ro.build.version.release': 15
[2358fa3b][ADB] Device API level: 35
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd package resolve-activity --brief com.android.chrome'
[2358fa3b][AndroidUiautomator2Driver@1a72] Using the default com.android.chrome activity com.google.android.apps.chrome.Main. Original error: Unable to resolve the launchable activity of 'com.android.chrome'. Original error: No activity found
[2358fa3b][AndroidUiautomator2Driver@1a72] Chrome-type package and activity are com.android.chrome and com.google.android.apps.chrome.Main
[2358fa3b][AndroidUiautomator2Driver@1a72] Starting 'com.android.chrome' directly on the device
[2358fa3b][AndroidUiautomator2Driver@1a72] Relaxing hidden api policy
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[2358fa3b][AndroidUiautomator2Driver@1a72] No app sent in, not parsing package/activity
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping'
[2358fa3b][AndroidUiautomator2Driver@1a72] Pushing settings apk to the device...
[2358fa3b][ADB] Getting package info for 'io.appium.settings'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[2358fa3b][ADB] Using 'aapt2' from '/opt/android-sdk/build-tools/34.0.0-rc2/aapt2'
[2358fa3b][ADB] Reading package manifest: '/opt/android-sdk/build-tools/34.0.0-rc2/aapt2 dump badging /home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
[2358fa3b][ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('5.12.19' >= '5.12.19')
[2358fa3b][ADB] There is no need to install/upgrade '/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd notification allow_listener io.appium.settings/.NLService'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell appops set io.appium.settings PROJECT_MEDIA allow'
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[2358fa3b][SettingsApp] Starting Appium Settings app
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start-activity -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER'
[2358fa3b][AndroidUiautomator2Driver@1a72] Error: Cannot start the 'io.appium.settings' application. Consider checking the driver's troubleshooting documentation. Original error: Error executing adbExec. Original error: 'Command '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start-activity -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' exited with code 1'; Command output: Error type 3
Error: Activity class {io.appium.settings/io.appium.settings.Settings} does not exist.
at ADB.startApp (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/apk-utils.js:226:11)
at SettingsApp.requireRunning (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/lib/client.js:75:5)
at AndroidUiautomator2Driver.pushSettingsApp (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/utils.js:252:5)
at AndroidUiautomator2Driver.initDevice (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:228:5)
[2358fa3b][AndroidUiautomator2Driver@1a72] Deleting UiAutomator2 session
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings/.recorder.RecorderService'
[2358fa3b][AndroidUiautomator2Driver@1a72] Restoring hidden api policy to the device default configuration
[2358fa3b][ADB] Running '/opt/android-sdk/platform-tools/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''
[2358fa3b][AppiumDriver@86c6] Event 'newSessionStarted' logged at 1734301730689 (22:28:50 GMT+0000 (Coordinated Universal Time))
[2358fa3b][AppiumDriver@86c6] Encountered internal error running command: Error: Cannot start the 'io.appium.settings' application. Consider checking the driver's troubleshooting documentation. Original error: Error executing adbExec. Original error: 'Command '/opt/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start-activity -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' exited with code 1'; Command output: Error type 3
Error: Activity class {io.appium.settings/io.appium.settings.Settings} does not exist.
at ADB.startApp (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-adb/lib/tools/apk-utils.js:226:11)
at SettingsApp.requireRunning (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/lib/client.js:75:5)
at AndroidUiautomator2Driver.pushSettingsApp (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/utils.js:252:5)
at AndroidUiautomator2Driver.initDevice (/home/user/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/device/common.js:228:5)
[2358fa3b][HTTP] <-- POST /session 500 28553 ms - 1494
[2358fa3b][ADB] [AVD OUTPUT] INFO | Boot completed in 33194 ms
[2358fa3b][ADB] [AVD OUTPUT] INFO | Increasing screen off timeout, logcat buffer size to 2M.
I'm not sure you already tried as no logs but did you try out appium:avdReadyTimeout?
Yes, I tried this. Above log with the following settings:
options.setUiautomator2ServerInstallTimeout(Duration.ofMinutes(5));
options.setUiautomator2ServerLaunchTimeout(Duration.ofMinutes(5));
options.setAvdReadyTimeout(Duration.ofMinutes(5));
options.setAvdLaunchTimeout(Duration.ofMinutes(5));
options.setAndroidInstallTimeout(Duration.ofMinutes(5));
options.setAdbExecTimeout(Duration.ofMinutes(5));
Please attache the full server log as a gist. It looks like emulator booting status then
https://gist.github.com/HSerg/ed8eda6e1743b375a4ca46eaa7dd1fc6
I don’t have development environment for now, so can’t check it out but it looks like emulator or android os related just after the os starts.
If the device has already been running, there is no error.
Did you check it when Appium started while the device was starting? So, the emulator was not up completed yet
I am having this exact same issue. The first test session on an Appium server fails while the emulator is still in the middle of booting up because "Activity class {io.appium.settings/io.appium.settings.Settings} does not exist." I increased avdReadyTimeout to 4 minutes, but it doesn't seem to be waiting the full duration. The emulator continues to boot after the session fails, and once it's fully booted all future sessions run as normal until the emulator/Appium server are restarted again.
Versions:
- MacOS Sequoia 15.3.1
- Appium: 2.15.0
- UIAutomator2: 4.0.1
- Android emulator: 35.3.11.0
- Android 15, image
system-images;android-35;google_apis;x86_64
Capabilities:
- "appium:adbExecTimeout": 120000,
- "appium:automationName": "UiAutomator2",
- "appium:newCommandTimeout": 600,
- "appium:noReset": true,
- "appium:avd": "Android-Tablet-6",
- "appium:udid": "emulator-5564",
- "appium:systemPort": 8236,
- "appium:chromedriverPort": 8136,
- "appium:avdArgs": "-port 5564",
- "appium:avdReadyTimeout": 240000
Full log: https://gist.github.com/EvSmithIB/7bd8939337d5b66696be25a4010cf9f2
any updates? i encountered this issue too
i found a temporary solution for this issue. the adb is actually working in the background, but webdriver say it is timeout. so to overcome this issue, you have to increase the connectionRetryCount.
export const config: WebdriverIo.Config = {
...config,
connectionRetryTimeout: 180_000,
connectionRetryCount: 10,
capabilities: [...]
}
but the connectionRetryTimeout seems not working (have no idea), so i increase the connectionRetryCount to 10, it works after webdriver retrying 4-5 times in the background to actually wait for adb response.
@KazuCocoa @mykola-mokhnach https://discuss.appium.io/t/android-cannot-set-the-device-locale-to-a-you-may-want-to-apply-one-of-the-following-locales-instead/44963 may have a common root cause with this issue. I regularly get the Locale verification has failed if don't run emulator beforehand.
Possibly https://github.com/appium/io.appium.settings/pull/223 fixed that timing issue. Please try out with the latest uia2 driver
Possibly appium/io.appium.settings#223 fixed that timing issue. Please try out with the latest uia2 driver
Perfect! The locale bug is gone. Thanks!
I got the same issue with the latest version. I also tried the -delay-adb option and no lucky.
It seems as long as AVD outputs "Boot completed" message, Appium can connect to emulator without issue.
I checked the source code at https://github.com/appium/appium-adb/blob/289914ec0de9942f99a8189fc82cffb6fa3646a4/lib/tools/system-calls.js#L937.
The API level I use is 36. It seems there are some timing issues, when shell cmd reboot_readiness check-subsystems-state --list-blocking returns true, the system is not fully booted yet and cause the above error.
If I add -no-boot-anim command line argument, it reduces the error chance from 100% to 50%. Maybe if UiAutomator2 can provide some options to control the delay (the default can be set to 0), it can workaround that issue.
@crmky I have updated the readiness check. Please try the latest driver version
I updated uiautomator2 to 5.0.4 version and everything works smoothly. I can always see Appium run adb command after AVD outputs "Boot completed" message.
Thanks @mykola-mokhnach for the fix!