appium 的版本:1.4.13.1

使用 selendroid 模式,appium 报错,错误如下:

Launching Appium server with command: D:\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --selendroid-port 8080 --platform-name Android --platform-version 19 --automation-name Selendroid --log-no-color
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"19","automationName":"Selendroid"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Selendroid","platformVersion":"4.4.4","app":"D:\workspace\SinaPocketTest\apps\app\whistle.apk","platformName":"Android","deviceName":"MI 3","appActivity":"com.ruijie.anan.ui.WelcomeActivity","udid":"13b74a4a","appPackage":"com.ruijie.whistle"}}
info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
info: [debug] Using local app from desired caps: D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] Creating new appium session 4e0cd9f4-ed76-4217-a7a9-e357a87a17bf
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.7.0_51
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe
info: [debug] Checking whether selendroid is built yet
info: [debug] Selendroid server exists!
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 13b74a4a
info: [debug] Setting device id to 13b74a4a
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a wait-for-device
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\android-4.4.2\aapt.exe
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\android-4.4.2\aapt.exe dump badging D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
info: [debug] Checking signed status of C:\Users\xushan3\AppData\Local\Temp\selendroid.com.ruijie.whistle.apk
info: [debug] Checking app cert for C:\Users\xushan3\AppData\Local\Temp\selendroid.com.ruijie.whistle.apk.
info: [debug] executing cmd: java -jar D:\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\xushan3\AppData\Local\Temp\selendroid.com.ruijie.whistle.apk
info: [debug] Checking signed status of D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] Checking app cert for D:\workspace\SinaPocketTest\apps\app\whistle.apk.
info: [debug] executing cmd: java -jar D:\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\xushan3\AppData\Local\Temp\selendroid.com.ruijie.whistle.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe -f 4 C:\Users\xushan3\AppData\Local\Temp\selendroid.com.ruijie.whistle.apk C:\Users\xushan3\AppData\Local\Temp\1151011-6412-18guupk\appium.tmp
info: [debug] App already signed.
info: [debug] Zip-aligning D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe -f 4 D:\workspace\SinaPocketTest\apps\app\whistle.apk C:\Users\xushan3\AppData\Local\Temp\1151011-6412-1o00zs9\appium.tmp
info: [debug] Rebuilt selendroid apk exists, doing nothing
info: [debug] Getting install status for com.ruijie.whistle.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "getprop ro.build.version.sdk"
info: [debug] MD5 for selendroid server is 2e3ab67cf2461b7308ee526f52401d47
info: [debug] Device is at API Level 19
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "pm list packages -3 com.ruijie.whistle.selendroid"
info: [debug] App is installed
info: [debug] Rebuilt selendroid is already installed
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: zh
info: [debug] java -jar "D:\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "D:\workspace\SinaPocketTest\apps\app\whistle.apk" "C:\Users\xushan3\AppData\Local\Temp\com.ruijie.whistle" zh
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for D:\workspace\SinaPocketTest\apps\app\whistle.apk.
info: [debug] executing cmd: java -jar D:\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] App already signed.
info: [debug] Zip-aligning D:\workspace\SinaPocketTest\apps\app\whistle.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\19.1.0\zipalign.exe -f 4 D:\workspace\SinaPocketTest\apps\app\whistle.apk C:\Users\xushan3\AppData\Local\Temp\1151011-6412-jn9soa\appium.tmp
info: [debug] MD5 for app is 0ad2fe905571a58c2f90677db025d886
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "ls /data/local/tmp/0ad2fe905571a58c2f90677db025d886.apk"
info: [debug] Getting install status for com.ruijie.whistle
info: [debug] Getting device API level
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "pm list packages -3 com.ruijie.whistle"
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "mkdir -p /data/local/tmp/"
info: [debug] Removing any old apks
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "ls /data/local/tmp/*.apk"
info: [debug] Found an apk we want to keep at /data/local/tmp/0ad2fe905571a58c2f90677db025d886.apk
info: [debug] Couldn't find any apks to remove
info: [debug] Uninstalling com.ruijie.whistle
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "am force-stop com.ruijie.whistle"
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a uninstall com.ruijie.whistle
info: [debug] App was not uninstalled, maybe it wasn't on device?
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "pm install -r /data/local/tmp/0ad2fe905571a58c2f90677db025d886.apk"
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a forward tcp:8080 tcp:8080
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a install "D:\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a install "D:\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] executing cmd: D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s 13b74a4a shell "am instrument -e main_activity 'com.ruijie.anan.ui.WelcomeActivity' com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation"

error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation

  at com.android.commands.am.Am.runInstrument(Am.java:865)

  at com.android.commands.am.Am.onRun(Am.java:282)

  at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)

  at com.android.commands.am.Am.main(Am.java:76)

  at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

  at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:245)

  at dalvik.system.NativeStart.main(Native Method)

info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation

info: [debug] Error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation

at D:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1394:17
at [object Object]. (D:\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:635:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation\r\r)","origValue":"android.util.AndroidException: INSTRUMENTATION_FAILED: com.ruijie.whistle.selendroid/io.selendroid.server.ServerInstrumentation\r\r"},"sessionId":null}
info: <-- POST /wd/hub/session 500 20139.358 ms - 384


java 代码为:

capabilities.setCapability("deviceName","MI 3");
capabilities.setCapability("automationName","Selendroid")
capabilities.setCapability("platformVersion", "4.4.4");
capabilities.setCapability("udid", udid);
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.ruijie.whistle");
capabilities.setCapability("appActivity", "com.ruijie.anan.ui.WelcomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:" + port + "/wd/hub"), capabilities);


查看了一下手机安装的 instrumentation


试过了一下方法都解决不了,请高人帮忙解决一下


↙↙↙阅读原文可查看相关链接,并与作者交流