Stderr: 'error: device unauthorized.
I get "device unauthorized" when i running a sample code which is from appium website ,
appium client code :
// javascript const wdio = require('webdriverio');
console.log("starting running test..."); // javascript const opts = { port: 4723, desiredCapabilities: { platformName: "Android", platformVersion: "7.1.2", deviceName: process.env.UDID, // app: "/Users/david/work/xw/stf-appium-example/apks/android-sample-app.apk", app: "/Users/david/work/xw/appium/files/demoApk/ApiDemos-debug.apk", automationName: "UiAutomator2" } };
const client = wdio.remote(opts);
// javascript client .init() .click("~App") .click("~Alert Dialogs") .back() .back() .end();
the command is :
DEVICE_SERIAL=b125680d7d04 ./scripts/run_integration_test.sh
appium log:
[debug] [BaseDriver] Creating session with MJSONWP desired capabilities: {"javascriptEnabled":true,"... [BaseDriver] The following capabilities were provided, but are not recognized by appium: javascriptEnabled, locationContextEnabled, handlesAlerts, rotatable, requestOrigins. [BaseDriver] Session created with session id: bc7c8cd7-f4be-4b7b-a839-70ccfed628d3 [BaseDriver] Using local app '/Users/david/work/xw/appium/files/demoApk/ApiDemos-debug.apk' [debug] [UiAutomator2] Checking whether app is actually present [debug] [AndroidDriver] Getting Java version [AndroidDriver] Java version is: 1.8.0_92 [AndroidDriver] Retrieving device list [debug] [ADB] Trying to find a connected android device [debug] [ADB] Getting connected devices... [debug] [ADB] 2 device(s) connected [AndroidDriver] Looking for a device with Android '7.1.2' [debug] [ADB] Setting device id to localhost:7401 [ADB] Getting device platform version [debug] [ADB] Running '/Users/david/tools/Library/Android/sdk/platform-tools/adb -P 5037 -s localhost:7401 shell getprop ro.build.version.release' [debug] [ADB] Running '/Users/david/tools/Library/Android/sdk/platform-tools/adb -P 5037 -s localhost:7401 shell getprop ro.build.version.release' [debug] [UiAutomator2] Deleting UiAutomator2 session [debug] [BaseDriver] Event 'newSessionStarted' logged at 1529116125651 (10:28:45 GMT+0800 (CST)) [MJSONWP] Encountered internal error running command: Error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command '/Users/david/tools/Library/Android/sdk/platform-tools/adb -P 5037 -s localhost:7401 shell getprop ro.build.version.release' exited with code 1'; Stderr: 'error: device unauthorized. [MJSONWP] This adb server's $ADB_VENDOR_KEYS is not set [MJSONWP] Try 'adb kill-server' if that seems wrong. [MJSONWP] Otherwise check for a confirmation dialog on your device.'; Code: '1' [MJSONWP] at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/adb-commands.js:89:11) [MJSONWP] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) [MJSONWP] at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)