Appium eclipse 中运行 case, 报 [AndroidDriver] Error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0)

庆生 · 2018年04月11日 · 最后由 庆生 回复于 2018年04月11日 · 2185 次阅读

windows 环境下,Appium Desktop1.4.0(Appium1.7.2)
在 eclipse 中运行 java 写的脚本,报错:
[AndroidDriver] Error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0)

下面是全部的 appium log,请问是什么原因
[Appium] Welcome to Appium v1.7.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.tebonsc","appActivity":"com.zztzt.android.simple.activity.tztCommHeadPageActivity","platformVersion":"24","automationName":"uiautomator2","sessionOverride":true,"unicodeKeyboard":true,"platformName":"Android","deviceName":"3HX5T17114002385","resetKeyboard":false,"autoAcceptAlerts":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"appPackage":"com.tebonsc","appActivity":"com.zztzt.android.simple.activity.tztCommHeadPageActivity","platformVersion":"24","automationName":"uiautomator2","sessionOverride":true,"unicodeKeyboard":true,"platformName":"Android","deviceName":"3HX5T17114002385","resetKeyboard":false,"autoAcceptAlerts":true},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1523423469668 (13:11:09 GMT+0800 (中国标准时间))
[Appium] Creating new AndroidUiautomator2Driver (v0.11.0) session
[Appium] Capabilities:
[Appium] appPackage: com.tebonsc
[Appium] appActivity: com.zztzt.android.simple.activity.tztCommHeadPageActivity
[Appium] platformVersion: 24
[Appium] automationName: uiautomator2
[Appium] sessionOverride: true
[Appium] unicodeKeyboard: true
[Appium] platformName: Android
[Appium] deviceName: 3HX5T17114002385
[Appium] resetKeyboard: false
[Appium] autoAcceptAlerts: true
[BaseDriver] The following capabilities were provided, but are not recognized by appium: sessionOverride, autoAcceptAlerts.
[BaseDriver] Session created with session id: 8694bac0-450c-429b-b0fc-f7b29eed8c62
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_161
[ADB] Checking whether adb is present
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '24'
[ADB] Setting device id to 3HX5T17114002385
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","3HX5T17114002385","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 7.0
[AndroidDriver] Error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0)
at Object.wrappedLogger.errorAndThrow (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Object.callee$0$0$ (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:165:16)
at tryCatch (C:\Users\wuqs\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 next
at GeneratorFunctionPrototype.invoke (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
Error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0)
at Object.wrappedLogger.errorAndThrow (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Object.callee$0$0$ (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:165:16)
at tryCatch (C:\Users\wuqs\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 next
at GeneratorFunctionPrototype.invoke (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[UiAutomator2] Deleting UiAutomator2 session
[MJSONWP] Encountered internal error running command: Error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0)
at Object.wrappedLogger.errorAndThrow (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at Object.callee$0$0$ (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:165:16)
at tryCatch (C:\Users\wuqs\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 next
at GeneratorFunctionPrototype.invoke (C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at
[HTTP] <-- POST /wd/hub/session 500 685 ms - 244

Eclipse 中部分 log 如下:
FAILED CONFIGURATION: @BeforeClass InitialAppTestDriver
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unable to find an active device or emulator with OS 24. The following are available: 3HX5T17114002385 (7.0) (WARNING: The server did not provide any stacktrace information)

共收到 10 条回复 时间 点赞

其实报错已经写的很明白了
Error: Unable to find an active device or emulator with OS 24
[Appium] platformVersion: 24 这个位置填错参数了

case 在 appium:1.4.16.1 用这个配置运行没报错啊,
手机也确实是 android 7.0(API 24),

渐次消逝 回复

怎么填,在哪填

庆生 回复

这个 DesiredCapabilities 设置的有问题吗
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "3HX5T17114002385");

capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "24");

// 配置测试 apk
capabilities.setCapability("appPackage", "com.tebonsc");
capabilities.setCapability("appActivity", "com.zztzt.android.simple.activity.tztCommHeadPageActivity");
capabilities.setCapability("sessionOverride", true); // 每次启动时覆盖 session,否则第二次后运行会报错不能新建 session
capabilities.setCapability("unicodeKeyboard", true); // 设置键盘
capabilities.setCapability("resetKeyboard", false); // 设置默认键盘为 appium 的键盘
capabilities.setCapability("automationName", "uiautomator2");

//ios 专用,当 iOS 的个人信息访问警告 (如 位置、联系人、图片) 出现时,自动选择接受 ( Accept )。默认值 false
capabilities.setCapability("autoAcceptAlerts", true);

if (isNotInstall) {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "TztTebonGenApp2-hs03-release.apk");
capabilities.setCapability("app", app.getAbsolutePath());
}

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

android7.0 你就填 7.0 而不是 24

雨夜狂奔 回复

换成 7.0 就不报连不上的错误了,但是报下面的错误:
[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s 3HX5T17114002385 install C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-ime\bin\UnicodeIME-debug.apk' exited with code 1'; Stderr: 'adb: failed to install C:\Users\wuqs\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-android-ime\bin\UnicodeIME-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package io.appium.android.ime signatures do not match the previously installed version; ignoring!]'; Code: '1'

庆生 回复

将手机上的 appium 相关的 app 卸载掉,appium-setting, appium inputxxx, appium-unlock 等等,仔细找找没有图标的很明显,都卸载掉之后再试下

雨夜狂奔 回复

appium-setting,appium-unlock 都从手机上卸载掉了,桌面上没找的 appium inputxxx

庆生 回复

appium android input,名字不一定准确,找到相关的卸载了试试就行

庆生 #10 · 2018年04月11日 Author
雨夜狂奔 回复

我把手机内的 appium 的预装的输入法卸载了,就好了。

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