Appium appium 启动 Android7.0 系统报错。Error: Cannot stop and clear com.hikvision.automobileblack. Original error: Error executing adbExec. Original error: 'Command ''C:\\Python27\\android SDK\\sdk\\platform-tools\\adb.exe' -P 5037 -s 8848ccdb shell pm clear com.hikvision.automobileblack' exited with code 1'; Stderr: 'Failed'; Code: '1'

yszj · 2018年06月08日 · 最后由 yszj 回复于 2018年06月11日 · 3594 次阅读

[info] [Appium] Welcome to Appium v1.7.1
[info] [Appium] Appium REST http interface listener started on 0.0.0.0:4723[info] [HTTP] --> POST /wd/hub/session {"capabilities":{"alwaysMatch":{"platformName":"Android"},"firstMatch":[{}]},"desiredCapabilities":{"deviceName":"MI6","url":"http://localhost:4723/wd/hub,automationName:UiAutomator2,udid:8848ccdb,platformVersion:7.1.1,appPackage:com.hikvision.automobileblack,platformName:Android,appActivity:com.hikvision.automobile.activity.SplashActivity}"}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"deviceName":"MI6","url":"http://localhost:4723/wd/hub,automationName:UiAutomator2,udid:8848ccdb,platformVersion:7.1.1,appPackage:com.hikvision.automobileblack,platformName:Android,appActivity:com.hikvision.automobile.activity.SplashActivity},null,{alwaysMatch:{platformName:Android},firstMatch:[{}]}"]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1528428037164 (11:20:37 GMT+0800 (中国标准时间))
[info] [Appium] Creating new AndroidUiautomator2Driver (v0.6.5) session
[info] [Appium] Capabilities:
[info] [Appium] deviceName: 'MI6'
[info] [Appium] url: 'http://localhost:4723/wd/hub'
[info] [Appium] automationName: 'UiAutomator2'
[info] [Appium] udid: '8848ccdb'
[info] [Appium] platformVersion: '7.1.1'
[info] [Appium] appPackage: 'com.hikvision.automobileblack'
[info] [Appium] platformName: 'Android'
[info] [Appium] appActivity: 'com.hikvision.automobile.activity.SplashActivity'
[warn] [BaseDriver] The following capabilities were provided, but are not recognized by appium: url.
[info] [BaseDriver] Session created with session id: 8e5993b0-f9ce-4c5e-845b-656d528ec57f[debug] [AndroidDriver] Getting Java version[info] [AndroidDriver] Java version is: 1.8.0_144
[info] [ADB] Checking whether adb is present
[info] [ADB] Using adb.exe from C:\Python27\android SDK\sdk\platform-tools\adb.exe
[info] [AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[info] [AndroidDriver] Using device: 8848ccdb
[info] [ADB] Checking whether adb is present
[info] [ADB] Using adb.exe from C:\Python27\android SDK\sdk\platform-tools\adb.exe
[debug] [ADB] Setting device id to 8848ccdb
[warn] [AndroidDriver] No app sent in, not parsing package/activity
[info] [ADB] Getting device platform version
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","getprop","ro.build.version.release"][debug] [ADB] Current device property 'ro.build.version.release': 7.1.1
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","wm","size"][debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","getprop","ro.product.model"][debug] [ADB] Current device property 'ro.product.model': MI 6
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","getprop","ro.product.manufacturer"]
[debug] [ADB] Current device property 'ro.product.manufacturer': Xiaomi
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","am","force-stop","io.appium.uiautomator2.server"][info] [ADB] Checking whether aapt is present
[info] [ADB] Using aapt.exe from C:\Python27\android SDK\sdk\build-tools\21.1.2\aapt.exe[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","list","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] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","list","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] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","dumpsys","package","io.appium.uiautomator2.server"][debug] [UiAutomator2] Waiting up to 20000ms for instrumentation 'io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner' to be available
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","list","instrumentation"][debug] [UiAutomator2] Instrumentation 'io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner' available
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","wait-for-device"][debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","echo","ping"][debug] [Logcat] Starting logcat capture[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Uninstalling and re-installing 'io.appium.settings'
[debug] [ADB] Uninstalling io.appium.settings
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","list","packages","io.appium.settings"][debug] [ADB] App is installed
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","am","force-stop","io.appium.settings"][debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","uninstall","io.appium.settings"][debug] [ADB] ADB command output: Success
[info] [ADB] io.appium.settings was successfully uninstalled
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","list","packages","io.appium.settings"][debug] [ADB] App is not installed
[debug] [ADB] App 'C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk' not installed. Installing
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","install","C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\io.appium.settings\app\build\outputs\apk\settings_apk-debug.apk"][debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","getprop","ro.build.version.sdk"][debug] [ADB] Current device property 'ro.build.version.sdk': 25
[debug] [ADB] Device API level: 25
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","dumpsys","package","io.appium.settings"][debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","dump","io.appium.settings"][debug] [ADB] Got the following command chunks to execute: pm,grant,io.appium.settings,android.permission.WRITE_SETTINGS,;,pm,grant,io.appium.settings,android.permission.ACCESS_FINE_LOCATION,;,pm,grant,io.appium.settings,android.permission.ACCESS_COARSE_LOCATION,;,pm,grant,io.appium.settings,android.permission.ACCESS_MOCK_LOCATION,;,pm,grant,io.appium.settings,android.permission.SET_ANIMATION_SCALE,;
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_FINE_LOCATION",";","pm","grant","io.appium.settings","android.permission.ACCESS_COARSE_LOCATION",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";","pm","grant","io.appium.settings","android.permission.SET_ANIMATION_SCALE",";"][debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_FINE_LOCATION",";","pm","grant","io.appium.settings","android.permission.ACCESS_COARSE_LOCATION",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";","pm","grant","io.appium.settings","android.permission.SET_ANIMATION_SCALE",";"][debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","ps"][debug] [ADB] Device API level: 25
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","am","start","-W","-n","io.appium.settings/.Settings","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"][debug] [ADB] Device API level: 25
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","appops","set","io.appium.settings","android:mock_location","allow"][debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","install","C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk"][debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","install","C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk"][debug] [ADB] Application 'C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk' already installed. Continuing.
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","forward","tcp:8200","tcp:6790"][debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","dumpsys","window"][info] [AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidDriver] Extracting strings from apk undefined undefined C:\Users\xujie7\AppData\Local\Temp\com.hikvision.automobileblack
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Device API level: 25
[debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","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] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","rm","-rf","/data/local/tmp/strings.json"][debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [AndroidDriver] Running fast reset (stop and clear)
[debug] [ADB] Getting connected devices...
[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","am","force-stop","com.hikvision.automobileblack"][debug] [ADB] Getting connected devices...[debug] [ADB] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","clear","com.hikvision.automobileblack"][debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","pm","clear","com.hikvision.automobileblack"][error] [ADB] Error: Cannot stop and clear com.hikvision.automobileblack. Original error: Error executing adbExec. Original error: 'Command ''C:\Python27\android SDK\sdk\platform-tools\adb.exe' -P 5037 -s 8848ccdb shell pm clear com.hikvision.automobileblack' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: PID 27894 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.hikvision.automobileblack'; Code: '1'
at Object.wrappedLogger.errorAndThrow (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
at ADB.callee$0$0$ (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:334:9)
at tryCatch (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at process._tickCallback (internal/process/next_tick.js:103:7)
Error: Cannot stop and clear com.hikvision.automobileblack. Original error: Error executing adbExec. Original error: 'Command ''C:\Python27\android SDK\sdk\platform-tools\adb.exe' -P 5037 -s 8848ccdb shell pm clear com.hikvision.automobileblack' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: PID 27894 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.hikvision.automobileblack'; Code: '1'
at Object.wrappedLogger.errorAndThrow (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
at ADB.callee$0$0$ (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:334:9)
at tryCatch (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at process._tickCallback (internal/process/next_tick.js:103:7)
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[warn] [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] 2 device(s) connected
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","shell","am","force-stop","com.hikvision.automobileblack"][debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running 'C:\Python27\android SDK\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","8848ccdb","forward","--remove","tcp:8200"]
[error] [MJSONWP] Encountered internal error running command: Error: Cannot stop and clear com.hikvision.automobileblack. Original error: Error executing adbExec. Original error: 'Command ''C:\Python27\android SDK\sdk\platform-tools\adb.exe' -P 5037 -s 8848ccdb shell pm clear com.hikvision.automobileblack' exited with code 1'; Stderr: 'Error: java.lang.SecurityException: PID 27894 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.hikvision.automobileblack'; Code: '1'
at Object.wrappedLogger.errorAndThrow (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
at ADB.callee$0$0$ (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:334:9)
at tryCatch (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\xujie7\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at process._tickCallback (internal/process/next_tick.js:103:7)
[info] [HTTP] <-- POST /wd/hub/session 500 30770 ms - 597

最佳回复

应该和 appium 没关系,这个是 adb 做 kill 进程的时候,没有权限,你把这个命令贴到命令行运行一下,看看是不是也是报的这个错误

共收到 4 条回复 时间 点赞

这是 8848 手机吗😂

应该和 appium 没关系,这个是 adb 做 kill 进程的时候,没有权限,你把这个命令贴到命令行运行一下,看看是不是也是报的这个错误

对的,你直接在命令行窗口中输入 adb 命令试试

yszj #4 · 2018年06月11日 Author
文贤平 回复

删除了手机中的 appium 安装的东西,重启了手机。不知道什么操作,莫名其妙就好了。还没执行你这个操作。下次还有遇到在试试。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册