Search code examples
androidnode.jsautomated-testsadbappium

Appium server having an error detecting platform version when running tests


I'm trying to run the basic test script on the test app provided by appium. I am using a physical device (Nexus 6p) with android version 8.1.0. This is the code I'm trying to run (Node.js):

const wdio = require("webdriverio");

const opts = {
  port: 4723,
  capabilities: {
    platformName: "Android",
    platformVersion: "8.1.0",
    deviceName: "Nexus 6P",
    app: "C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk",
    automationName: "UiAutomator2"
  }
};

const client = wdio.remote(opts);

start = async function () {
  const elementId = await client.findElement("accessibility id", "TextField1"); client.elementSendKeys(elementId.ELEMENT, "Hello World!");
  const elementValue = await client.findElement("accessibility id", "TextField1");
  await client.getElementAttribute(elementValue.ELEMENT, "value").then((attr) => {
    assert.equal(attr, "Hello World!");
  });
}

After running the code, and watching the client and server side-by-side, an error occurs this is what is shown in the client section:

    ERROR webdriver: Request failed due to unknown error: An unknown server-side error occurred while processing the command. Original error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
    at getErrorFromResponseBody (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\utils.js:343:10)
    at Request._callback (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\request.js:121:64)
    at Request.self.callback (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.EventEmitter.emit (domain.js:441:20)
    at Request.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:189:13)
    at Request.EventEmitter.emit (domain.js:441:20)
    at IncomingMessage.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
(node:8844) UnhandledPromiseRejectionWarning: unknown error: An unknown server-side error occurred while processing the command. Original error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
    at getErrorFromResponseBody (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\utils.js:343:10)
    at Request._callback (C:\Users\JH044350\Documents\Node\node_modules\webdriver\build\request.js:121:64)
    at Request.self.callback (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.EventEmitter.emit (domain.js:441:20)
    at Request.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:189:13)
    at Request.EventEmitter.emit (domain.js:441:20)
    at IncomingMessage.<anonymous> (C:\Users\JH044350\Documents\Node\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
(node:8844) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8844) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

And this is what I'm getting on the appium server logs:

[debug] [BaseDriver] Event 'newSessionRequested' logged at 1552053337834 (08:55:37 GMT-0500 (Colombia Standard Time))
[BaseDriver] The capabilities ["platformVersion","deviceName","app","automationName"] are not standard capabilities and should have an extension prefix
[Appium] Creating new AndroidUiautomator2Driver (v1.29.1) session
[Appium] Capabilities:
[Appium]   platformName: Android
[Appium]   platformVersion: 8.1.0
[Appium]   deviceName: Nexus 6P
[Appium]   app: C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk
[Appium]   automationName: UiAutomator2
[debug] [BaseDriver] W3C capabilities {"alwaysMatch":{"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {"alwaysMatch":{"platformNa...
[BaseDriver] Session created with session id: c771d923-3d27-4a63-887f-def40f07b38f
[BaseDriver] Using local app 'C:/Users/JH044350/Documents/Node/ApiDemos-debug.apk'
[debug] [UiAutomator2] Checking whether app is actually present
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '8.1.0'
[debug] [ADB] Setting device id to 84B7N16602000138
[ADB] Getting device platform version
[debug] [ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release'
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1552053338655 (08:55:38 GMT-0500 (Colombia Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command ''C:\\Program Files (x86)\\Android\\android-sdk\\platform-tools\\adb.exe' -P 5037 -s 84B7N16602000138 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'
[debug] [W3C]     at ADB.methods.getPlatformVersion (C:\Users\JH044350\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:108:11)
[HTTP] <-- POST /wd/hub/session 500 830 ms - 1201

The main error seems to be it being unable to find the platform version of the phone. when i run the code they are tryingg adb shell getprop ro.build.version.release I get the correct out put (8.1.0). I would like any help I could get to steer me in the right direction.


Solution

  • This issue was solved by downgrading adb version. The above was attempted using adb versions 1.0.39 and then 1.0.40. I downloaded adb 1.0.36 from xda developers and copied and pasted the files to my platform-tools folder and replaced the duplicates. After running the test again. It was completed successfully without issues. It seems appium isn’t compatible with the new adb. Maybe it’s the new command set in the newer adb versions, as some of the older commands were deprecated.