问答 appium setCapability (MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2) 命令行报错

战 神 · March 01, 2018 · Last by 🌀鸣人❤️一樂🍜 replied at March 06, 2019 · 4145 hits

扒了很久网站信息未得到解决,未设置ui2属性情况下,命令行启动server,脚本运行正常,而且很奇怪的是在桌面ui版appium-server下设置UI2属性是运行正常的
具体报错日志如下,有没有朋友也遇到过相同的坑? 目前排查跟zipalign.exe这个工具无关:

[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","getpro
p"
,"ro.product.model"]
[debug] [ADB] Current device property 'ro.product.model': Google Nexus 5X - 6.0.
0 - API 23 - 1080x1920
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","getpro
p"
,"ro.product.manufacturer"]
[debug] [ADB] Current device property 'ro.product.manufacturer': Genymotion
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","am","f
orce-stop"
,"io.appium.uiautomator2.server"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\build-
tools\27.0.3\aapt.exe
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","pm","l
ist"
,"packages","io.appium.uiautomator2.server"]
[debug] [ADB] App is installed
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","pm","l
ist"
,"packages","io.appium.uiautomator2.server.test"]
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for io.appium.uiautomator2.server
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","dumpsy
s"
,"package","io.appium.uiautomator2.server"]
[debug] [UiAutomator2] Waiting up to 20000ms for instrumentation 'io.appium.uiau
tomator2.server.test/android.support.test.runner.AndroidJUnitRunner' to be avail
able
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","pm","l
ist"
,"instrumentation"]
[debug] [UiAutomator2] Instrumentation 'io.appium.uiautomator2.server.test/andro
id.support.test.runner.AndroidJUnitRunner' available
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","wait-for-devic
e"
]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","echo",
"ping"]
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","pm","l
ist"
,"packages","io.appium.settings"]
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for io.appium.settings
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","dumpsy
s"
,"package","io.appium.settings"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\build-
tools\27.0.3\aapt.exe
[debug] [ADB] The installed 'io.appium.settings' package does not require upgrad
e ('2.3.0' >= '2.3.0')
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","ps"]
[debug] [AndroidDriver] io.appium.settings is already running. There is no need
to reset its permissions.
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","appops
"
,"set","io.appium.settings","android:mock_location","allow"]
[AndroidDriver] setDeviceLanguageCountry requires language or country.
[AndroidDriver] Got language: 'null' and country: 'null'
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Enabling Unicode keyboard support
[debug] [AndroidDriver] Pushing unicode ime to device...
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","install","C:\\
Users\\samfu.KAISER\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\
_appium-android-ime@2.0.0@appium-android-ime\\bin\\UnicodeIME-debug.apk"
]
[debug] [ADB] Install command stdout: [100%] /data/local/tmp/UnicodeIME-debug.ap
k
C:\Users\samfu.KAISER\AppData\Roaming\npm\node_modules\appium\node_modules\_appi
um-android-ime@2.0.0@appi...deIME-debug.apk: 1 file pushed. 0.5 MB/s (36795 byte
s in 0.065s)
pkg: /data/local/tmp/UnicodeIME-debug.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
[debug] [ADB] Application 'C:\Users\samfu.KAISER\AppData\Roaming\npm\node_module
s\appium\node_modules\_appium-android-ime@2.0.0@appium-android-ime\bin\UnicodeIM
E-debug.apk' already installed. Continuing.
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","settin
gs"
,"get","secure","default_input_method"]
[debug] [AndroidDriver] Unsetting previous IME com.android.inputmethod.latin/.La
tinIME
[debug] [AndroidDriver] Setting IME to 'io.appium.android.ime/.UnicodeIME'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","ime","
enable"
,"io.appium.android.ime/.UnicodeIME"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","ime","
set"
,"io.appium.android.ime/.UnicodeIME"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Getting install status for io.appium.unlock
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","pm","l
ist"
,"packages","io.appium.unlock"]
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for io.appium.unlock
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","dumpsy
s"
,"package","io.appium.unlock"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\build-
tools\27.0.3\aapt.exe
[debug] [ADB] The installed 'io.appium.unlock' package does not require upgrade
('2.0.0' >= '2.0.0')
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","forward","tcp:
8200"
,"tcp:6790"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","dumpsy
s"
,"window"]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidDriver] Extracting strings from apk C:\Users\samfu.KAISER\IdeaPr
ojects\apptest\apps\ContactManager.apk null C:\Users\SAMFU~1.KAI\AppData\Local\T
emp\com.example.android.contactmanager
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","getpro
p"
,"persist.sys.locale"]
[debug] [ADB] Current device property 'persist.sys.locale':
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","getpro
p"
,"ro.product.locale"]
[debug] [ADB] Current device property 'ro.product.locale': en-US
[debug] [ADB] No strings.xml for language 'en', getting default strings.xml
[debug] [ADB] Reading strings from converted strings.json
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","push","C:\\Use
rs\\SAMFU~1.KAI\\AppData\\Local\\Temp\\com.example.android.contactmanager\\strin
gs.json"
,"/data/local/tmp"]
[debug] [ADB] Checking app cert for C:\Users\samfu.KAISER\IdeaProjects\apptest\a
pps\ContactManager.apk
[ADB] Using apksigner.bat from C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\b
uild-tools\27.0.3\apksigner.bat
[ADB] Using apksigner.bat from C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\b
uild-tools\27.0.3\apksigner.bat
[debug] [ADB] Patching 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\build-to
ols\27.0.3\apksigner.bat' for Windows...
[debug] [ADB] Starting patched 'C:\Users\SAMFU~1.KAI\AppData\Local\Temp\201821-8
736-yhnhf.c2sbjg\apksigner.bat' with args 'verify,C:\Users\samfu.KAISER\IdeaProj
ects\apptest\apps\ContactManager.apk'
[debug] [ADB] 'C:\Users\samfu.KAISER\IdeaProjects\apptest\apps\ContactManager.ap
k' is already signed.
[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] [UiAutomator2] Resetting IME to 'com.android.inputmethod.latin/.LatinIME
'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","ime","
set"
,"com.android.inputmethod.latin/.LatinIME"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","shell","am","f
orce-stop"
,"com.example.android.contactmanager"]
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running 'C:\Users\samfu.KAISER\AppData\Local\Android\Sdk\platform-
tools\adb.exe' with args: ["-P",5037,"-s","192.168.198.101:5555","forward","--re
move"
,"tcp:8200"]
[MJSONWP] Encountered internal error running command: TypeError: helpers.install
ApkRemotely is not a function
at AndroidUiautomator2Driver.initAUT$ (../../lib/driver.js:387:21)
at tryCatch (C:\Users\samfu.KAISER\AppData\Roaming\npm\node_modules\appium\n
ode_modules\_babel-runtime@5.8.24@babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\samfu.KAISER\App
Data\Roaming\npm\node_modules\appium\node_modules\_babel-runtime@5.8.24@babel-ru
ntime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\U
sers\samfu.KAISER\AppData\Roaming\npm\node_modules\appium\node_modules\_babel-ru
ntime@5.8.24@babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\samfu.KAISER\AppData\Roaming\
npm\node_modules\appium\node_modules\_babel-runtime@5.8.24@babel-runtime\regener
ator\runtime.js:136:37)
at <anonymous>
[HTTP] <-- POST /wd/hub/session 500 7712 ms - 181

共收到 9 条回复 时间 点赞
战 神 #1 · March 01, 2018 作者

Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id 关键词,但是找了手机中 两个ui2server的apk都有安装

战 神 #2 · March 02, 2018 作者

暴力解决法:把node_modules下的LIB,BIN等文件夹下所有的js文件替换了,问题OK😹

战 神 回复

你替换成什么了,我这边报错Did not get confirmation UiAutomator2 deleteSession worke

先谢谢楼主,遇到了同样的问题,楼主可能没说太清楚,再说一下解决方法,希望对大家有帮助!
在appium-desktop上尝试使用uiautomation2看能否正常运行,若能正常运行,使用appium-desktop目录下的appium\node_modules,将命令行安装的appium\node_modules替换掉就可以成功运行了。

战 神 #5 · March 14, 2018 作者
xcc 回复

把npm内node_modules下的LIB,BIN等文件夹下所有的js文件内容替换成appium桌面版的内容

战 神 #6 · March 14, 2018 作者
终结者 回复

是的 基本只能暴力做法

今天启动appium时也遇到了相同的报错,可以交流一下吗?邮箱地址 rainbowxiamm@163.com

xiao 回复

上面有说啊 ,1.最好***下。 2.如果有缺失直接把桌面版的内容copy过来 ,但还是有风险。

战 神 回复

对待妹纸温油点呀。兄嘚

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up