adb devices 可以识别手机,但是执行脚本过程中 linux 服务器老报 device not found 错误,我再本地 windows 系统中运行正常。

(node:8303) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[36minfo[39m: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
[36minfo[39m: Appium REST http interface listener started on 0.0.0.0:10003
[36minfo[39m: [debug] Non-default server args: {"udid":"BIUSJRCIRCW8NJJJ","port":10003,"bootstrapPort":20003,"defaultCommandTimeout":600}
[36minfo[39m: Console LogLevel: debug
[36minfo[39m: [37m-->[39m [37mPOST[39m [37m/wd/hub/session[39m [90m{"desiredCapabilities":{"deviceName":"BIUSJRCIRCW8NJJJ","unicodeKeyboard":true,"udid":"BIUSJRCIRCW8NJJJ","automationName":"Appium","resetKeyboard":true,"platformVersion":"5.1","appPackage":"com.android.dialer","platformName":"Android","appActivity":".DialtactsActivity"}}[39m
[36minfo[39m: Client User-Agent string: Python-urllib/2.7
[36minfo[39m: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
[36minfo[39m: [debug] Creating new appium session 9a392b1e-500f-442e-a951-bc536ff05354
[36minfo[39m: Starting android appium
[36minfo[39m: [debug] Getting Java version
[36minfo[39m: Java version is: 1.8.0_51
[36minfo[39m: [debug] Checking whether adb is present
[36minfo[39m: [debug] Using adb from /home/yulore/android-sdk-linux/platform-tools/adb
[33mwarn[39m: No app capability, can't parse package/activity
[36minfo[39m: [debug] Using fast reset? true
[36minfo[39m: [debug] Preparing device for session
[36minfo[39m: [debug] Not checking whether app is present since we are assuming it's already on the device
[36minfo[39m: Retrieving device
[36minfo[39m: [debug] Trying to find a connected android device
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb devices
[36minfo[39m: [debug] 2 device(s) connected
[36minfo[39m: Found device BIUSJRCIRCW8NJJJ
[36minfo[39m: [debug] Setting device id to BIUSJRCIRCW8NJJJ
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "echo 'ready'"
[36minfo[39m: [debug] Starting logcat capture
[36minfo[39m: [debug] Getting device API level
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "getprop ro.build.version.sdk"
[36minfo[39m: [debug] Device is at API Level 19
[36minfo[39m: Device API level is: 19
[36minfo[39m: [debug] Extracting strings for language: default
[36minfo[39m: [debug] Apk doesn't exist locally
[36minfo[39m: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "rm -rf /data/local/tmp/strings.json"
[36minfo[39m: [debug] Not uninstalling app since server not started with --full-reset
[36minfo[39m: [debug] Skipping install since we launched with a package instead of an app path
[36minfo[39m: [debug] Forwarding system:20003 to device:4724
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ forward tcp:20003 tcp:4724
[36minfo[39m: [debug] Pushing appium bootstrap to device...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ push "/usr/local/avm/versions/1.4.16/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar" /data/local/tmp/
[36minfo[39m: [debug] Enabling Unicode keyboard support
[36minfo[39m: [debug] Pushing unicode ime to device...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ install "/usr/local/avm/versions/1.4.16/node_modules/appium/build/unicode_ime_apk/UnicodeIME-debug.apk"
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "settings get secure default_input_method"
[36minfo[39m: [debug] Unsetting IME 'io.appium.android.ime/.UnicodeIME'
[36minfo[39m: [debug] Setting IME to 'io.appium.android.ime/.UnicodeIME'
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "ime enable io.appium.android.ime/.UnicodeIME"
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "ime set io.appium.android.ime/.UnicodeIME"
[36minfo[39m: [debug] Pushing settings apk to device...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ install "/usr/local/avm/versions/1.4.16/node_modules/appium/build/settings_apk/settings_apk-debug.apk"
[36minfo[39m: [debug] Pushing unlock helper app to device...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ install "/usr/local/avm/versions/1.4.16/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"
[36minfo[39m: Starting App
[36minfo[39m: [debug] Attempting to kill all 'uiautomator' processes
[36minfo[39m: [debug] Getting all processes with 'uiautomator'
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "ps 'uiautomator'"
[36minfo[39m: [debug] No matching processes found
[36minfo[39m: [debug] Running bootstrap
[36minfo[39m: [debug] spawning: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.dialer -e disableAndroidWatchers false
[36minfo[39m: [debug] [33m[UIAUTOMATOR STDERR] error: protocol fault (couldn't read status): Success[39m
[36minfo[39m: [debug] [33m[UIAUTOMATOR STDERR] [39m
[36minfo[39m: [debug] Logcat terminated with code 0, signal null
[36minfo[39m: [debug] UiAutomator exited
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "echo 'ping'"
[36minfo[39m: [debug] Error: Command failed: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ shell "echo 'ping'"
error: device 'BIUSJRCIRCW8NJJJ' not found

[36minfo[39m: [debug] Stopping logcat capture
[36minfo[39m: [debug] Logcat already stopped
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ kill-server
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] Retrying restartAdb
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ kill-server
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ devices
[36minfo[39m: [debug] 1 device(s) connected
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] Retrying restartAdb
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ kill-server
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ devices
[36minfo[39m: [debug] 1 device(s) connected
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] Retrying restartAdb
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ kill-server
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ devices
[36minfo[39m: [debug] 1 device(s) connected
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ kill-server
[36minfo[39m: [debug] Getting connected devices...
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ devices
[36minfo[39m: [debug] 1 device(s) connected
[36minfo[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
[36minfo[39m: [debug] executing cmd: /home/yulore/android-sdk-linux/platform-tools/adb -s BIUSJRCIRCW8NJJJ wait-for-device
[36minfo[39m: [debug] Device did not become ready in 5 secs; are you sure it's powered on?
[36minfo[39m: [debug] Attempting to uninstall app
[36minfo[39m: [debug] Not uninstalling app since server not started with --full-reset
[36minfo[39m: [debug] Cleaning up android objects
[31merror[39m: UiAutomator quit before it successfully launched
[36minfo[39m: [debug] Cleaning up appium session
[31merror[39m: Failed to start an Appium session, err was: Error: UiAutomator quit before it successfully launched
[36minfo[39m: [debug] Error: UiAutomator quit before it successfully launched
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android.js:205:23)
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android-hybrid.js:249:5)
at Object.async.eachSeries (/usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/async/lib/async.js:142:20)
at androidHybrid.stopChromedriverProxies (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android-hybrid.js:233:9)
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android.js:200:10)
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android.js:222:9)
at androidCommon.uninstallApp (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android-common.js:478:5)
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android.js:220:12)
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/lib/devices/android/android.js:245:15)
at /usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/async/lib/async.js:251:17
at /usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/async/lib/async.js:148:21
at /usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/async/lib/async.js:248:21
at /usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/async/lib/async.js:612:34
at . (/usr/local/avm/versions/1.4.16/node_modules/appium/node_modules/appium-adb/lib/adb.js:930:9)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
[36minfo[39m: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: UiAutomator quit before it successfully launched)","origValue":"UiAutomator quit before it successfully launched"},"sessionId":null}
Message: A new session could not be created. (Original error: UiAutomator quit before it successfully launched)


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