问答 [请教] appium1.6.3 的版本在 capabilities 配置使用 uiautomator2 之后报创建 session 出错

小胖。 · March 23, 2017 · Last by 小胖。 replied at March 30, 2017 · Last modified by admin 恒温 · 3848 hits

环境配置:

Appium: appium@1.6.3
jdk: 1.8.0_102
platformVersion: 6.0'
automationName: 'uiautomator2'
platformName: 'Android'

代码配置项:

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);

启动后报错信息:

前端:

appium后端错误信息:

PS:如果注释掉uiautomator2的配置项,可正常运行,但是无法获取到toast等。

完整日志:

[Appium] Welcome to Appium v1.6.3
[Appium] Non-default server args:
[Appium] sessionOverride: true
[Appium] chromeDriverPort: 9515
[Appium] udid: '02157df2a362e31c'
[Appium] Deprecated server args:
[Appium] -U,--udid => --default-capabilities '{"udid":"02157df2a362e31c"}'
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] udid: '02157df2a362e31c'
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"E:\\work\\globaleautotest\\apps\\com.globalegrow.app.gearbest_2.1.0.apk","appPackage":"com.globalegrow.app.gearbest","deviceName":"10.33.4.172:5555","deviceReadyTimeout":"30","appActivity":".MainActivity","newCommandTimeout":"300","platformVersion":"6.0.1","automationName":"UIAutomator2","unicodeKeyboard":"True","platformName":"Android","udid":"02157df2a362e31c","resetKeyboard":"True"},"requiredCapabilities":{}},"desiredCapabilities":{"app":"E:\\work\\globaleautotest\\apps\\com.globalegrow.app.gearbest_2.1.0.apk","appPackage":"com.globalegrow.app.gearbest","deviceName":"10.33.4.172:5555","deviceReadyTimeout":"30","appActivity":".MainActivity","newCommandTimeout":"300","platformVersion":"6.0.1","automationName":"UIAutomator2","unicodeKeyboard":"True","platformName":"Android","udid":"02157df2a362e31c","resetKeyboard":"True"},"requiredCapabilities":{}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"E:\\work\\globaleautotest\\apps\\com.globalegrow.app.gearbest_2.1.0.apk","appPackage":"com.globalegrow.app.gearbest","deviceName":"10.33.4.172:5555","deviceReadyTimeout":"30","appActivity":".MainActivity","newCommandTimeout":"300","platformVersion":"6.0.1","automationName":"UIAutomator2","unicodeKeyboard":"True","platformName":"Android","udid":"02157df2a362e31c","resetKeyboard":"True"},{},{"desiredCapabilities":{"app":"E:\\work\\globaleautotest\\apps\\com.globalegrow.app.gearbest_2.1.0.apk","appPackage":"com.globalegrow.app.gearbest","deviceName":"10.33.4.172:5555","deviceReadyTimeout":"30","appActivity":".MainActivity","newCommandTimeout":"300","platformVersion":"6.0.1","automationName":"UIAutomator2","unicodeKeyboard":"True","platformName":"Android","udid":"02157df2a362e31c","resetKeyboard":"True"},"requiredCapabilities":{}},null,null]
[Appium] Creating new AndroidUiautomator2Driver session
[Appium] Capabilities:
[Appium] app: 'E:\\work\\globaleautotest\\apps\\com.globalegrow.app.gearbest_2.1.0.apk'
[Appium] appPackage: 'com.globalegrow.app.gearbest'
[Appium] deviceName: '10.33.4.172:5555'
[Appium] deviceReadyTimeout: '30'
[Appium] appActivity: '.MainActivity'
[Appium] newCommandTimeout: '300'
[Appium] platformVersion: '6.0.1'
[Appium] automationName: 'UIAutomator2'
[Appium] unicodeKeyboard: 'True'
[Appium] platformName: 'Android'
[Appium] udid: '02157df2a362e31c'
[Appium] resetKeyboard: 'True'
[BaseDriver] Capability 'unicodeKeyboard' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Capability 'resetKeyboard' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Capability 'newCommandTimeout' changed from string ('300') to integer (300). This may cause unexpected behavior
[BaseDriver] Capability 'deviceReadyTimeout' changed from string ('30') to integer (30). This may cause unexpected behavior
[BaseDriver] Session created with session id: 2507ed69-e9c8-458c-8442-96cfb4766576
[BaseDriver] Using local app 'E:\work\globaleautotest\apps\com.globalegrow.app.gearbest_2.1.0.apk'
[debug] [UiAutomator2] Checking whether app is actually present
[UiAutomator2] UIAutomator2 Driver version:0.2.3
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_121

[ADB] Checking whether adb is present
[ADB] Using adb.exe from E:\工作\自动化\adt\sdk\platform-tools\adb.exe
[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] Using device: 02157df2a362e31c
[ADB] Checking whether adb is present
[ADB] Using adb.exe from E:\工作\自动化\adt\sdk\platform-tools\adb.exe
[debug] [ADB] Setting device id to 02157df2a362e31c
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","getprop","ro.build.version.release"]
[debug] [ADB] Attempting to kill all io.appium.uiautomator2.server processes
[debug] [ADB] Getting all processes with io.appium.uiautomator2.server
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","ps"]
[ADB] No io.appium.uiautomator2.server process found to kill, continuing...
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","wait-for-device"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","echo","ping"]
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Enabling Unicode keyboard support
[debug] [AndroidDriver] Pushing unicode ime to device...
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","install","C:\\Users\\Huxuebing\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-ime\\bin\\UnicodeIME-debug.apk"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","settings","get","secure","default_input_method"]
[debug] [AndroidDriver] Unsetting previous IME io.appium.android.ime/.UnicodeIME
[debug] [AndroidDriver] Setting IME to 'io.appium.android.ime/.UnicodeIME'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","ime","enable","io.appium.android.ime/.UnicodeIME"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","ime","set","io.appium.android.ime/.UnicodeIME"]
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","install","C:\\Users\\Huxuebing\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\io.appium.settings\\bin\\settings_apk-debug.apk"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","install","C:\\Users\\Huxuebing\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-debug.apk"]
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","forward","tcp:8200","tcp:6790"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidDriver] Extracting strings from apk E:\work\globaleautotest\apps\com.globalegrow.app.gearbest_2.1.0.apk null C:\Users\HUXUEB~1\AppData\Local\Temp\com.globalegrow.app.gearbest
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","getprop","ro.build.version.sdk"]
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","getprop","persist.sys.locale"]
[debug] [ADB] Current device property 'persist.sys.locale': zh-CN
[debug] [ADB] No strings.xml for language 'zh', getting default strings.xml
[debug] [ADB] Reading strings from converted strings.json
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","push","C:\\Users\\HUXUEB~1\\AppData\\Local\\Temp\\com.globalegrow.app.gearbest\\strings.json","/data/local/tmp"]
[debug] [ADB] Checking app cert for E:\work\globaleautotest\apps\com.globalegrow.app.gearbest_2.1.0.apk.
[debug] [ADB] App already signed.
[debug] [ADB] Zip-aligning 'E:\work\globaleautotest\apps\com.globalegrow.app.gearbest_2.1.0.apk'
[ADB] Checking whether zipalign is present
[ADB] Using zipalign.exe from E:\工作\自动化\adt\sdk\build-tools\android-4.4W\zipalign.exe
[debug] [ADB] Zip-aligning apk.
[AndroidDriver] Remote apk path is /data/local/tmp/3042686cce642ce6165c6f7c5a05dc26.apk
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","ls","/data/local/tmp/3042686cce642ce6165c6f7c5a05dc26.apk"]
[debug] [AndroidDriver] Checking if app is installed
[debug] [ADB] Getting install status for com.globalegrow.app.gearbest
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","pm","list","packages","-3","com.globalegrow.app.gearbest"]
[debug] [ADB] App is installed
[AndroidDriver] Apk is already on remote and installed, resetting
[debug] [AndroidDriver] Running fast reset (stop and clear)
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","am","force-stop","com.globalegrow.app.gearbest"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","pm","clear","com.globalegrow.app.gearbest"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from E:\工作\自动化\adt\sdk\build-tools\android-4.4W\aapt.exe
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","shell","am","force-stop","com.globalegrow.app.gearbest"]
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running 'E:\工作\自动化\adt\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","02157df2a362e31c","forward","--remove","tcp:8200"]
Error: write EPIPE
at exports._errnoException (util.js:1022:11)
at Socket._writeGeneric (net.js:712:26)
at Socket._write (net.js:731:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at Socket.Writable.write (_stream_writable.js:247:11)
at Socket.write (net.js:658:40)
at Socket.stream.write (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\ansi\lib\newlines.js:36:21)
at Console.log (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\lib\winston\transports\console.js:119:20)
at transportLog (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\lib\winston\logger.js:234:15)
at C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\node_modules\async\lib\async.js:157:13
at _each (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\node_modules\async\lib\async.js:57:9)
at Object.async.each (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\node_modules\async\lib\async.js:156:9)
at Logger.log (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\lib\winston\logger.js:246:9)
at target.(anonymous function) [as error] (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\winston\lib\winston\common.js:54:18)
at EventEmitter.<anonymous> (../../lib/logsink.js:199:25)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at EventEmitter.<anonymous> (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\npmlog\log.js:158:8)
at EventEmitter.<anonymous> (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\npmlog\log.js:231:21)
at asyncHandler$ (../../../lib/mjsonwp/mjsonwp.js:267:13)
at tryCatch (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\Huxuebing\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 14 条回复 时间 点赞

没人遇到过么?在线等解答。

小胖。 回复

围观。。。。

小胖。 回复

Windows 7环境下有appium 1.6.3?

山姆 回复

有的

小胖。 回复

请教一下,windows下你是怎么安装appium1.6.3的?

山姆 回复

官网有写。。。

没人知道么?。。。

日志也太少了

恒温 回复

完整日志已补充,帮忙看看呢。谢了

小胖。 #10 · March 28, 2017 作者

@kasi @seveniruby @Lihuazhang 帮忙看看呢,已安装appium-uiautomator2-driver ,2个apk手机上也有了。

不是去掉这个capabilities就行了吗 ?

小胖。 #12 · March 30, 2017 作者
E度丶塔罗 回复

去掉了就无法获取toast了

小胖。 回复

我之前写的时候也是加上这个capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2); 就没办法打开 ,但是去掉之后就能获取提示,不知道是不是版本的问题。我用的是三星s7edge 6.0.1的系统

小胖。 #14 · March 30, 2017 作者
E度丶塔罗 回复

去掉之后无法获取toast

小胖。 关闭了讨论 31 Mar 11:37
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up