Appium [求助-Appium 1.2.0] 遇到两个问题,一个是无法启动应用,一个是无法使用 API<17 的

vincent · 2014年08月02日 · 最后由 丧尸没有牙齿 回复于 2017年06月07日 · 3112 次阅读

环境:
Windows 7
Appium 1.2.0 for windoows
appium.exe
AppiumDriver
备注:用的 Python 跟 Java 都一样的问题

问题一:
许久没有使用 Appium,回来后更新了 1.2 版本,但是发现一个奇葩问题,为什么无法自动启动已安装的应用?Appium 解锁后手动运行程序后可继续跑脚本,如果不手动运行会 Timeout 结束,贴 LOG

> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.4.4","platformName":"Android","deviceName":"148904d2"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.4.4","platformName":"Android","deviceName":"148904d2"}}
> info: Retrieving device
> ERROR: debug: Didn't get app but did get Android package, will attempt to launch it on the device
> ERROR: debug: Creating new appium session 26ca6b5b-851e-417b-bc0f-539f7e024b25
> ERROR: debug: Using fast reset? true
> ERROR: debug: Preparing device for session
> ERROR: debug: Not checking whether app is present since we are assuming it's already on the device
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 61625b81
> ERROR: debug: Setting device id to 61625b81
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> warn: No app capability, can't parse package/activity
> ERROR: debug: Getting device API level
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "getprop ro.build.version.sdk"
> ERROR: debug: Device is at API Level 19
> info: Device API level is: 19
> ERROR: debug: Apk doesn't exist locally
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "rm -rf /data/local/tmp/strings.json"
> ERROR: debug: Not uninstalling app since server not started with --full-reset
> ERROR: debug: Skipping install since we launched with a package instead of an app path
> ERROR: debug: Forwarding system:4724 to device:4724
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 forward tcp:4724 tcp:4724
> ERROR: debug: Pushing appium bootstrap to device...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 push "E:\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
> ERROR: debug: Pushing settings apk to device...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 install "E:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> ERROR: debug: Pushing unlock helper app to device...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 install "E:\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
> info: Starting App
> ERROR: debug: Attempting to kill all 'uiautomator' processes
> ERROR: debug: Getting all processes with 'uiautomator'
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "ps 'uiautomator'"
> ERROR: debug: No matching processes found
> ERROR: debug: Running bootstrap
> ERROR: debug: spawning: E:\android-sdk-windows\platform-tools\adb.exe -s 61625b81 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> ERROR: debug: [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> ERROR: debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
> ERROR: debug: [BOOTSTRAP] [debug] Socket opened on port 4724
> ERROR: debug: [BOOTSTRAP] [debug] Appium Socket Server Ready
> ERROR: debug: [BOOTSTRAP] [debug] Loading json...
> ERROR: debug: Waking up device if it's not alive
> ERROR: debug: Pushing command to appium work queue: ["wake",{}]
> ERROR: debug: [BOOTSTRAP] [debug] Registered crash watchers.
> ERROR: debug: [BOOTSTRAP] [debug] Client connected
> ERROR: debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
> ERROR: debug: [BOOTSTRAP] [debug] Got command of type ACTION
> ERROR: debug: [BOOTSTRAP] [debug] Got command action: wake
> ERROR: debug: [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window"
> ERROR: debug: Writing dumpsys output to E:\Appium\node_modules\appium\.dumpsys.log
> info: Unlocking screen
> ERROR: debug: Screen is locked, trying to unlock
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window"
> ERROR: debug: Writing dumpsys output to E:\Appium\node_modules\appium\.dumpsys.log
> ERROR: debug: Screen is unlocked, continuing
> ERROR: debug: Pushing command to appium work queue: ["getDataDir",{}]
> ERROR: debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
> ERROR: debug: [BOOTSTRAP] [debug] Got command of type ACTION
> ERROR: debug: [BOOTSTRAP] [debug] Got command action: getDataDir
> ERROR: debug: [BOOTSTRAP] [debug] Returning result: {"value":"\/data\/local\/tmp","status":0}
> ERROR: debug: dataDir set to: /data/local/tmp
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.test.android.app/.ui.main.MainActivity"
> ERROR: debug: Waiting for pkg "com.test.android.app" and activity ".ui.main.MainActivity" to be focused
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Getting focused package and activity
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "dumpsys window windows"
> ERROR: debug: Device launched! Ready for commands
> info: <-- POST /wd/hub/session 303 20725.861 ms - 9 
> ERROR: debug: Setting command timeout to the default of 60 secs
> ERROR: debug: Appium session started with sessionId 26ca6b5b-851e-417b-bc0f-539f7e024b25
> info: --> GET /wd/hub/session/26ca6b5b-851e-417b-bc0f-539f7e024b25 {}
> ERROR: debug: Appium request initiated at /wd/hub/session/26ca6b5b-851e-417b-bc0f-539f7e024b25
> info: <-- GET /wd/hub/session/26ca6b5b-851e-417b-bc0f-539f7e024b25 200 2.179 ms - 534 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.4.4","platformName":"Android","deviceName":"148904d2"},"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformName":"Android","deviceName":"148904d2"},"sessionId":"26ca6b5b-851e-417b-bc0f-539f7e024b25"}
> ERROR: debug: Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.4.4","platformName":"Android","deviceName":"148904d2"},"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformName":"Android","deviceName":"148904d2"},"sessionId":"26ca6b5b-851e-417b-bc0f-539f7e024b25"}

LOG 很长,至此 APP 启动过程结束,才会执行下一句的代码,实在无法理解为何不自动启动应用了。。

问题二:
使用了 selendroid 后,仍然告诉我没有大于 17 的 API 设备,贴 LOG

> Starting Node Server
> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.1.2","automationName":"Selendroid","platformName":"Android","deviceName":"148904d2"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"appPackage":"com.test.android.app","appActivity":".ui.main.MainActivity","platformVersion":"4.1.2","automationName":"Selendroid","platformName":"Android","deviceName":"148904d2"}}
> info: Retrieving device
> ERROR: debug: Didn't get app but did get Android package, will attempt to launch it on the device
> ERROR: debug: Creating new appium session bbcb99fe-20b2-4436-b552-7ad4c2b2e765
> ERROR: debug: Starting selendroid server
> ERROR: debug: Checking whether selendroid is built yet
> ERROR: debug: Selendroid server exists!
> ERROR: debug: Preparing device for session
> ERROR: debug: Not checking whether app is present since we are assuming it's already on the device
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 61625b81
> ERROR: debug: Setting device id to 61625b81
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> warn: No app capability, can't parse package/activity
> ERROR: debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
> ERROR: debug: Uninstalling com.test.android.app.selendroid
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "am force-stop com.test.android.app.selendroid"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 uninstall com.test.android.app.selendroid
> ERROR: debug: App was not uninstalled, maybe it wasn't on device?
> ERROR: debug: Rebuilt selendroid server does not exist, inserting modified manifest
> ERROR: debug: Inserting selendroid manifest
> info: <-- POST /wd/hub/session 500 2712.442 ms - 220 
> ERROR: debug: Checking whether aapt is present
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: Compiling manifest C:\Windows\Temp\com.test.android.app\AndroidManifest.xml
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
> ERROR: debug: Error: Required platform doesn't exist (API level >= 17)
> ERROR:     at ADB.compileManifest (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:290:15)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:390:16)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
> ERROR:     at iterate (E:\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> ERROR:     at ADB.checkSdkBinaryPresent (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:113:5)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:388:30)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}

LOG 截止,贴代码,此代码在问题一与问题中无任何修改,仅是否注释 automationName 的参数:

@Before
public void setUp() throws Exception {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "148904d2");
        capabilities.setCapability("platformVersion", "4.1.2");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("appPackage", "com.test.android.app");
        capabilities.setCapability("appActivity", ".ui.main.MainActivity");
        capabilities.setCapability("automationName", "Selendroid");
        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),
        capabilities);

    }
共收到 26 条回复 时间 点赞

从贴出的 log 和 code 来看 有两个疑问

1.看 og 中找到的设备为 61625b81

但代码中的 deviceName 为
148904d2

2.第 2 个问题中

ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"19","automationName":"Appium"}

appium 启动时,就已经指定了 platformVersion 为 19

#1 楼 @umbrella1978
设备 ID 的问题:我试过 ID 不过也可以正常启动所以我就没有每次都换 ID 了;
问题 2:启动后就指定了 19 的 API,这个问题我也不知道怎么回事。。所以我才提问的。。不知道是不是 1.2 的问题还是我的代码有问题- - 或者是一些我目前还不知道的因素导致的。

#2 楼 @vincent
无法启动应用这个问题,从 log 上看一直再等待找被测应用的动作,你提到有锁屏,这个最好将锁屏取消了,因为 appium 那个自动解锁不稳定,然后再试试

另外你是用 nodejs 更新 appium 的吗,启动的时候指定了 sdk 为 19,和代码无关,可能是 appium 服务端的配置导致的

#3 楼 @umbrella1978
倒是想起一个可能,我一开始是装了 nodejs 上的 appium 的,后来才转用 appiumfor win 的;晚点我卸载掉 node 的版本看看还有没有这个问题,其实我以前用 0.X 版本的时候就已经没有办法使用低版本的系统了,只是当时学习也没有怎么管这个问题,毕竟小问题;
刚才我看了下我 exe 里面的设置的确是有默认的值- - 是 4.2 的。。我一会儿试试

锁屏的我试过解锁后才使用也一样无法启动,而且解锁的功能目前在我这里看起来是挺正常的~每次都可以正常解锁手机,只是解锁后就不知道去启动应用了- -

还有一个因素不知道是不是跟我用的系统有关系,我用的是 CM 的,晚点也找其它人的设备试下~

有问题我再找你~谢谢你~

#3 楼 @umbrella1978
在 exe 里面换了 4.1 的还是不可以,设备是 4.1.2 报的错基本是一样的,已删除 node 上的 appium。

> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"Android","automationName":"Selendroid","platformVersion":"4.1","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","deviceName":"61625b81"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"platformName":"Android","automationName":"Selendroid","platformVersion":"4.1","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","deviceName":"61625b81"}}
> info: Retrieving device
> ERROR: debug: Didn't get app but did get Android package, will attempt to launch it on the device
> ERROR: debug: Creating new appium session eb8eee56-a665-4fad-b3fa-51e8a0bc2972
> ERROR: debug: Starting selendroid server
> ERROR: debug: Checking whether selendroid is built yet
> ERROR: debug: Selendroid server exists!
> ERROR: debug: Preparing device for session
> ERROR: debug: Not checking whether app is present since we are assuming it's already on the device
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 148904d2
> ERROR: debug: Setting device id to 148904d2
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> warn: No app capability, can't parse package/activity
> ERROR: debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
> ERROR: debug: Uninstalling com.test.android.app.selendroid
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "am force-stop com.test.android.app.selendroid"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 uninstall com.test.android.app.selendroid
> ERROR: debug: App was not uninstalled, maybe it wasn't on device?
> ERROR: debug: Rebuilt selendroid server does not exist, inserting modified manifest
> ERROR: debug: Inserting selendroid manifest
> info: <-- POST /wd/hub/session 500 2153.804 ms - 220 
> ERROR: debug: Checking whether aapt is present
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: Compiling manifest C:\Windows\Temp\com.test.android.app\AndroidManifest.xml
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
> ERROR: debug: Error: Required platform doesn't exist (API level >= 17)
> ERROR:     at ADB.compileManifest (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:290:15)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:390:16)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
> ERROR:     at iterate (E:\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> ERROR:     at ADB.checkSdkBinaryPresent (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:113:5)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:388:30)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}

刚刚看日志时看到是不是无法自动启动应用是因为 1.2 自身的 BUG- -
日志里面有解析报错

> warn: No app capability, can't parse package/activity

#5 楼 @vincent

capabilities.setCapability("deviceName", deviceName);
capabilities.setCapability("platformVersion", platformVersion);
capabilities.setCapability("platformName", platformName);
capabilities.setCapability("app", appPath);
capabilities.setCapability("appPackage", appPackage);
capabilities.setCapability("appActivity", appActivity);

把 app 的路径加上
capabilities.setCapability("app", appPath);
Selendroid 需要将重新打包被测应用,所以要设置被测 app 在本地的目录
另外,刚启动时显示的 platformverison 是指 PC 上安装的 sdk 版本,是我理解错了,和那个没有关系。

#6 楼 @umbrella1978
但是我是启动设备上已安装的程序,如果是这样就没有办法了,但是试下后还是不可以- - 感觉问题越来越奇怪了。。

> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.1","app":"F:\\Download\\test.apk","platformName":"Android","appActivity":"ui.main.MainActivity","deviceName":"61625b81","appPackage":"com.test.android.app","automationName":"Selendroid"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"platformVersion":"4.1","app":"F:\\Download\\test.apk","platformName":"Android","appActivity":"ui.main.MainActivity","deviceName":"61625b81","appPackage":"com.test.android.app","automationName":"Selendroid"}}
> ERROR: debug: Using local app from desired caps: F:\Download\test.apk
> ERROR: debug: Creating new appium session 46274a47-3a53-4fc8-abb0-bd825c826268
> ERROR: debug: Starting selendroid server
> ERROR: debug: Checking whether selendroid is built yet
> ERROR: debug: Selendroid server exists!
> ERROR: debug: Preparing device for session
> ERROR: debug: Checking whether app is actually present
> ERROR: debug: Checking whether adb is present
> info: Retrieving device
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> info: Found device 148904d2
> ERROR: debug: 1 device(s) connected
> ERROR: debug: Setting device id to 148904d2
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> ERROR: debug: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
> ERROR: debug: Uninstalling com.test.android.app.selendroid
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 shell "am force-stop com.test.android.app.selendroid"
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 148904d2 uninstall com.test.android.app.selendroid
> ERROR: debug: App was not uninstalled, maybe it wasn't on device?
> ERROR: debug: Rebuilt selendroid server does not exist, inserting modified manifest
> ERROR: debug: Inserting selendroid manifest
> ERROR: debug: Checking whether aapt is present
> info: <-- POST /wd/hub/session 500 2166.004 ms - 220 
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: Compiling manifest C:\Windows\Temp\com.test.android.app\AndroidManifest.xml
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
> ERROR: debug: Error: Required platform doesn't exist (API level >= 17)
> ERROR:     at ADB.compileManifest (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:290:15)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:390:16)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:610:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:249:17
> ERROR:     at iterate (E:\Appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:160:25
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:251:21
> ERROR:     at E:\Appium\node_modules\appium\node_modules\async\lib\async.js:615:34
> ERROR:     at ADB.checkSdkBinaryPresent (E:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:113:5)
> ERROR:     at null.<anonymous> (E:\Appium\node_modules\appium\lib\devices\android\selendroid.js:388:30)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}

#7 楼 @vincent 如果必须使用 selendroid 模式的话,那就得设置 app 的路径。

就怕没有变化,这次 log 中有变化了,看起来只剩下
debug: Error: Required platform doesn't exist (API level >= 17)
这个报错了,你是将 android sdk 的环境变量设置为低于 17 的版本了吗,你本机安装的 sdk 版本是多少?

info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
info: Appium REST http interface listener started on 127.0.0.1:4723

这里显示 appium 启动时,使用的 android sdk 的 platformVersion 为 16,说明环境变量里设置的 sdk 路径是 16 的路径,确实没有达到 api level >= 17 的要求

#8 楼 @umbrella1978

SDK 是最新的 23.0.2(我不太确认你说的 SDK 环境变量是哪个 SDK- -感觉应该是 Android 吧)
我现在要在 4.1.2 上运行,所以 exe 里面我就选了 16 的,刚刚选回 19 还是一样报错了~

18楼 已删除

#8 楼 @umbrella1978
刚刚才看就删除了- - 我已经找了,没有这个代码

#11 楼 @vincent 嗯 感觉没找到问题根源

#11 楼 @vincent 你测的是 webview 类型的 app 吗?如果没必要使用 selendroid 的话,

回到最初,不使用 selendroid,但要设置 app 的本地路径,尝试一下

在你第一次尝试的时候,log 中提示

warn: No app capability, can't parse package/activity
ERROR: debug: Apk doesn't exist locally`

#13 楼 @umbrella1978
那就是用 4.4 的设备咯~
设置了,但乱码了。。没有解锁手机

> Starting Node Server
> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"61625b81","app":"F:\\Download\\test.apk","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","platformVersion":"4.4","platformName":"Android"}}
> ERROR: debug: Appium request initiated at /wd/hub/session
> ERROR: debug: Request received with params: {"desiredCapabilities":{"deviceName":"61625b81","app":"F:\\Download\\test.apk","appPackage":"com.test.android.app","appActivity":"ui.main.MainActivity","platformVersion":"4.4","platformName":"Android"}}
> info: Starting android appium
> ERROR: debug: Using local app from desired caps: F:\Download\test.apk
> ERROR: debug: Creating new appium session ba2e0a0b-5419-4438-a876-5262cdbb07c6
> info: Retrieving device
> ERROR: debug: Using fast reset? true
> ERROR: debug: Preparing device for session
> ERROR: debug: Checking whether app is actually present
> ERROR: debug: Checking whether adb is present
> ERROR: debug: Using adb from E:\android-sdk-windows\platform-tools\adb.exe
> ERROR: debug: Trying to find a connected android device
> ERROR: debug: Getting connected devices...
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" devices
> ERROR: debug: 1 device(s) connected
> info: Found device 61625b81
> ERROR: debug: Setting device id to 61625b81
> ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 wait-for-device
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo 'ready'"
> ERROR: debug: Starting logcat capture
> ERROR: debug: Getting device API level
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "getprop ro.build.version.sdk"
> ERROR: debug: Device is at API Level 19
> info: Device API level is: 19
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "getprop persist.sys.language"
> ERROR: debug: Current device language: en
> ERROR: debug: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\Download\test.apk" "C:\Windows\Temp\com.test.android.app" en
> ERROR: debug: No strings.xml for language 'en', getting default strings.xml
> ERROR: debug: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\Download\test.apk" "C:\Windows\Temp\com.test.android.app"
> warn: Error getting strings.xml from apk
> ERROR: debug: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR: 
> ERROR: debug: executing: "E:\android-sdk-windows\platform-tools\adb.exe" -s 61625b81 shell "echo '{}' > /data/local/tmp/strings.json"
> ERROR: debug: Checking whether aapt is present
> ERROR: debug: Using aapt from E:\android-sdk-windows\build-tools\20.0.0\aapt.exe
> ERROR: debug: processFromManifest: "E:\android-sdk-windows\build-tools\20.0.0\aapt.exe" dump xmltree "F:\Download\test.apk" AndroidManifest.xml
> ERROR: debug: Set app process to: com.test.android.app
> ERROR: debug: Not uninstalling app since server not started with --full-reset
> ERROR: debug: Checking app cert for F:\Download\test.apk: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "F:\Download\test.apk"
> ERROR: debug: App not signed with debug cert.
> ERROR: debug: Resigning apk with: java -jar "E:\Appium\node_modules\appium\node_modules\appium-adb\jars\sign.jar" "F:\Download\test.apk" --override
> ERROR: debug: Stopping logcat capture
> ERROR: debug: Logcat terminated with code null, signal SIGTERM
> ERROR: debug: Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> ERROR: debug: Cleaning up android objects
> ERROR: debug: Cleaning up appium session
> ERROR: error: Failed to start an Appium session, err was: Error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR: 
> ERROR: debug: Error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷
> ERROR: 锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷
> ERROR: 
> ERROR:     at ChildProcess.exithandler (child_process.js:637:15)
> ERROR:     at ChildProcess.EventEmitter.emit (events.js:98:17)
> ERROR:     at maybeClose (child_process.js:743:16)
> ERROR:     at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> ERROR: debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷\r\n锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷\r\n)","killed":false,"code":1,"signal":null,"origValue":"Command failed: 'java' 锟斤拷锟斤拷锟节诧拷锟斤拷锟解部锟斤拷锟筋,也锟斤拷锟角匡拷锟斤拷锟叫的筹拷锟斤拷\r\n锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷\r\n"},"sessionId":null}

#13 楼 @umbrella1978
对了,貌似代码里面设置是否使用 selendroid 的优先级没有在 exe 里面设置的高。。我刚才忘记设置回 exe 的 selendroid 为 appium,然后一直报错- -

#13 楼 @umbrella1978 我今晚有事在加班~回你可能晚点,不好意思啊~

楼主问题解决没得呢,我也是遇到这个问题

#17 楼 @cdheyue 没有- -暂时不用呗~哈哈,等更新看看吧,反正我这段时间比较忙

自己已经解决

#19 楼 @cdheyue 怎么搞的?

@vincent ,你的问题解决了吗?我遇到和你一样的情况了,乱码,求助哈

@vincent @cdheyue @peiqiangsheng 你们的问题解决了吗?
我也遇到了同样的问题

楼上怎么解决的 我也遇到了

后来我自己解决了,发现是启动的 activity 不对。

乱码问题解决了吗?

看看是不是环境变量没有配置好。

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