Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot start Appium session on real android device with Mac M1 - Device UDID is being dropped by Appium #19713

Closed
3 tasks done
tmlop opened this issue Jan 26, 2024 · 4 comments
Labels
Bug a problem that needs fixing

Comments

@tmlop
Copy link

tmlop commented Jan 26, 2024

Do I have the most recent component updates?

  • I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I attempt to start an appium session on a real android device, I get the following error:
ERROR webdriver: Request failed with status 500 due to unknown error: An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: 'Command '/Users/mainUser/Library/Android/sdk/platform-tools/adb -P 5037 -s shell getprop ro.build.version.sdk' exited with code 1'; Command output: error: device '' not found

The "appium:udid" capability is set to the value displayed when running adb devices and even if I omit this value, I still get the same error.

As can be seen, Appium is attempting run the command adb -s <UDID> shell, but the <UDID> is getting dropped.

In the logs there is even a line that shows an empty udid (Setting device id to ):
[ADB] Running '/Users/mainUser/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[ADB] Setting device id to
[ADB] Running '/Users/mainUser/Library/Android/sdk/platform-tools/adb -P 5037 -s shell getprop ro.build.version.sdk'

This error occurs when running appium via code and in the appium inspector.

These are the session capabilities that are being used:
{
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:udid": "AAA985SOP2"
}

Please note that I can successfully run an appium session on a real iOS device using the same machine with the same appium installation, simply with different appium capabilities. This issue is only occurring on Android

Expected Behavior

  1. Appium should perform the command /Users/mainUser/Library/Android/sdk/platform-tools/adb -P 5037 -s AAA985SOP2 shell getprop ro.build.version.sdk
  2. An appium session should get start successfully

Minimal Reproducible Example

const {remote} = require('webdriverio');

const capabilities = {
platformName: 'Android',
'appium:automationName': 'UiAutomator2',
'appium:udid': 'AAA985SOP2'
};

const wdOpts = {
hostname: process.env.APPIUM_HOST || 'localhost',
port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
logLevel: 'info',
capabilities,
};

async function runTest() {
const driver = await remote(wdOpts);
try {
const batteryItem = await driver.$('//*[@text="Battery"]');
await batteryItem.click();
} finally {
await driver.pause(1000);
await driver.deleteSession();
}
}

runTest().catch(console.error);

Environment

  • Operating system: Mac M1 running Sonoma 14.2.1
  • Appium server version (output of appium --version): 2.4.1
  • Appium driver(s) and their version(s): xcuitest@5.14.0, uiautomator2@2.43.0
  • Appium plugin(s) and their version(s): N/A
  • Node.js version (output of node --version): v20.10.0
  • npm version (output of npm --version): 10.2.3
  • Last component(s) version which did not exhibit the problem: Same environment, just using real ios device and the corresponding udid for the ios device
  • Platform and version under test: Android, version 12
  • Real device or emulator/simulator: Real device

Link to Appium Logs

https://gist.github.com/tmlop/8e5b1e43e4aaca899af094d77c6782f2

Further Information

No response

@tmlop tmlop added Bug a problem that needs fixing Needs Triage bugs which are not yet confirmed labels Jan 26, 2024
@mykola-mokhnach mykola-mokhnach removed the Needs Triage bugs which are not yet confirmed label Jan 26, 2024
@KazuCocoa
Copy link
Member

appium/appium-uiautomator2-driver#724 should help

@mykola-mokhnach
Copy link
Collaborator

The patch has been deployed in the driver version 2.43.1

@lundstrj
Copy link

Can confirm that https://www.npmjs.com/package/appium-uiautomator2-driver/v/2.43.1 solves this specific problem 👍

@tmlop
Copy link
Author

tmlop commented Jan 26, 2024

Thanks so much! Can also confirm that https://www.npmjs.com/package/appium-uiautomator2-driver/v/2.43.1 solves this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug a problem that needs fixing
Projects
None yet
Development

No branches or pull requests

4 participants