测试人社区

appium 运行报错

[Appium] Welcome to Appium v1.20.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: 4db87b35-cdc4-4fc4-9dff-9340374475eb
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]},"desiredCapabilities":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},null,{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1610503940437 (19:12:20 GMT-0700 (Mountain Standard Time))
[Appium] 
[Appium] ======================================================================
[Appium]   DEPRECATION WARNING:
[Appium] 
[Appium]   The 'automationName' capability was not provided in the desired 
[Appium]   capabilities for this Android session
[Appium] 
[Appium]   Setting 'automationName=UiAutomator2' by default and using the 
[Appium]   UiAutomator2 Driver
[Appium] 
[Appium]   The next major version of Appium (2.x) will **require** the 
[Appium]   'automationName' capability to be set for all sessions on all 
[Appium]   platforms
[Appium] 
[Appium]   In previous versions (Appium <= 1.13.x), the default was 
[Appium]   'automationName=UiAutomator1'
[Appium] 
[Appium]   If you wish to use that automation instead of UiAutomator2, please 
[Appium]   add 'automationName=UiAutomator1' to your desired capabilities
[Appium] 
[Appium]   For more information about drivers, please visit 
[Appium]   http://appium.io/docs/en/about-appium/intro/ and explore the 
[Appium]   'Drivers' menu
[Appium] 
[Appium] ======================================================================
[Appium] 
[Appium] Appium v1.20.0 creating new AndroidUiautomator2Driver (v1.61.0) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "android",
[debug] [BaseDriver]     "appium:deviceName": "977707a29807",
[debug] [BaseDriver]     "appium:appPackage": "com.app_qa",
[debug] [BaseDriver]     "appium:appActivity": "com.wisdom_dyeing_fe_rn_demo_pre.MainActivity",
[debug] [BaseDriver]     "appium:dontStopAppOnReset": false,
[debug] [BaseDriver]     "appium:newCommandTimeout": 6000,
[debug] [BaseDriver]     "appium:noReset": true
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 9a598a1e-a862-430e-b955-fa539b32d48b
[UiAutomator2] Starting 'com.app_qa' directly on the device
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1610503940729 (19:12:20 GMT-0700 (Mountain Standard Time))
[debug] [W3C] Encountered internal error running command: Error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
[debug] [W3C]     at requireSdkRoot (/usr/local/lib/node_modules/appium/node_modules/_appium-adb@8.9.2@appium-adb/lib/helpers.js:36:11)
[debug] [W3C]     at Function.createADB (/usr/local/lib/node_modules/appium/node_modules/_appium-adb@8.9.2@appium-adb/lib/adb.js:55:23)
[debug] [W3C]     at Object.createBaseADB (/usr/local/lib/node_modules/appium/node_modules/_appium-android-driver@4.41.2@appium-android-driver/lib/android-helpers.js:108:20)
[debug] [W3C]     at Object.getDeviceInfoFromCaps (/usr/local/lib/node_modules/appium/node_modules/_appium-android-driver@4.41.2@appium-android-driver/lib/android-helpers.js:193:29)
[debug] [W3C]     at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:327:40)
[debug] [W3C]     at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:224:18)
[debug] [W3C]     at processTicksAndRejections (node:internal/process/task_queues:93:5)
[debug] [W3C]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] <-- POST /wd/hub/session 500 428 ms - 865

ANDROID_HOME 这个环境变量没有配置

这句日志已经告诉你问题原因了,是说没有正确的设置ANDROID_HOME变量,需要把这个变量设置指向到你的sdk目录,可以看下
https://developer.android.com/studio/command-line/variables

系统:ubuntu16.4

安装好Android SDK,后在终端输入android报错,发现安装的SDK没有 adb,在SDK目录下没有platform-tools,linux无界面,请教怎么办:

root@ubuntu:/usr/local/android-sdk-linux# android 
Exception in thread "main" org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
        at org.eclipse.swt.SWT.error(Unknown Source)
        at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
        at org.eclipse.swt.widgets.Display.create(Unknown Source)
        at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
        at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
        at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
        at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
        at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
        at org.eclipse.swt.widgets.Shell.<init>(Unknown Source)
        at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.createShell(SdkUpdaterWindowImpl2.java:168)
        at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.open(SdkUpdaterWindowImpl2.java:137)
        at com.android.sdkuilib.repository.SdkUpdaterWindow.open(SdkUpdaterWindow.java:111)
        at com.android.sdkmanager.Main.showSdkManagerWindow(Main.java:413)
        at com.android.sdkmanager.Main.doAction(Main.java:391)
        at com.android.sdkmanager.Main.run(Main.java:151)
        at com.android.sdkmanager.Main.main(Main.java:117)
info AppiumDoctor Appium Doctor v.1.16.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor  ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor  ✔ Node version is 15.5.1
info AppiumDoctor  ✔ ANDROID_HOME is set to: /usr/local/android-sdk-linux
info AppiumDoctor  ✔ JAVA_HOME is set to: /usr/local/java/jdk1.8.0_77
info AppiumDoctor    Checking adb, android, emulator
info AppiumDoctor      'android' is in /usr/local/android-sdk-linux/tools/android
info AppiumDoctor      'emulator' is in /usr/local/android-sdk-linux/tools/emulator
WARN AppiumDoctor  ✖ adb could NOT be found in /usr/local/android-sdk-linux!
info AppiumDoctor  ✔ 'bin' subfolder exists under '/usr/local/java/jdk1.8.0_77'
info AppiumDoctor ### Diagnostic for necessary dependencies completed, one fix needed. ###
info AppiumDoctor 
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor  ✖ opencv4nodejs cannot be found.
info AppiumDoctor  ✔ ffmpeg is installed at: /usr/bin/ffmpeg. ffmpeg version 2.8.17-0ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
WARN AppiumDoctor  ✖ mjpeg-consumer cannot be found.
WARN AppiumDoctor  ✖ bundletool.jar cannot be found
WARN AppiumDoctor  ✖ gst-launch-1.0 and/or gst-inspect-1.0 cannot be found
info AppiumDoctor ### Diagnostic for optional dependencies completed, 4 fixes possible. ###
info AppiumDoctor 
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor  ➜ Manually install adb and add it to PATH. https://developer.android.com/studio#cmdline-tools and https://developer.android.com/studio/intro/update#sdk-manager may help to setup.
info AppiumDoctor 
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor  ➜ Why opencv4nodejs is needed and how to install it: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md
WARN AppiumDoctor  ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.
WARN AppiumDoctor  ➜ bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it
WARN AppiumDoctor  ➜ gst-launch-1.0 and gst-inspect-1.0 are used to stream the screen of the device under test. Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details
info AppiumDoctor 
info AppiumDoctor ###
info AppiumDoctor 
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor 

adb是在sdk目录下的/platform-tools/下,这个目录你需要添加的PATH变量里。

这个你得看看你的SWT的jar包的问题了。

[Appium] Welcome to Appium v1.20.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: 8b65d288-b808-4f09-ba48-c54cc35a399f
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]},"desiredCapabilities":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},null,{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1610551928309 (08:32:08 GMT-0700 (Mountain Standard Time))
[Appium] 
[Appium] ======================================================================
[Appium]   DEPRECATION WARNING:
[Appium] 
[Appium]   The 'automationName' capability was not provided in the desired 
[Appium]   capabilities for this Android session
[Appium] 
[Appium]   Setting 'automationName=UiAutomator2' by default and using the 
[Appium]   UiAutomator2 Driver
[Appium] 
[Appium]   The next major version of Appium (2.x) will **require** the 
[Appium]   'automationName' capability to be set for all sessions on all 
[Appium]   platforms
[Appium] 
[Appium]   In previous versions (Appium <= 1.13.x), the default was 
[Appium]   'automationName=UiAutomator1'
[Appium] 
[Appium]   If you wish to use that automation instead of UiAutomator2, please 
[Appium]   add 'automationName=UiAutomator1' to your desired capabilities
[Appium] 
[Appium]   For more information about drivers, please visit 
[Appium]   http://appium.io/docs/en/about-appium/intro/ and explore the 
[Appium]   'Drivers' menu
[Appium] 
[Appium] ======================================================================
[Appium] 
[Appium] Appium v1.20.0 creating new AndroidUiautomator2Driver (v1.61.0) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "android",
[debug] [BaseDriver]     "appium:deviceName": "977707a29807",
[debug] [BaseDriver]     "appium:appPackage": "com.app_qa",
[debug] [BaseDriver]     "appium:appActivity": "com.wisdom_dyeing_fe_rn_demo_pre.MainActivity",
[debug] [BaseDriver]     "appium:dontStopAppOnReset": false,
[debug] [BaseDriver]     "appium:newCommandTimeout": 6000,
[debug] [BaseDriver]     "appium:noReset": true
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: cf28646b-f043-434f-afb4-dbbc71be9de0
[UiAutomator2] Starting 'com.app_qa' directly on the device
[ADB] Found 1 'build-tools' folders under '/usr/local/android-sdk-linux' (newest first):
[ADB]     /usr/local/android-sdk-linux/build-tools/29.0.3
[ADB] Using 'adb' from '/usr/local/android-sdk-linux/platform-tools/adb'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 start-server'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices
[debug] [ADB] Connected devices: [{"udid":"977707a29807","state":"device"}]
[AndroidDriver] Using device: 977707a29807
[ADB] Using 'adb' from '/usr/local/android-sdk-linux/platform-tools/adb'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 start-server'
[debug] [ADB] Setting device id to 977707a29807
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Getting device platform version
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 9
[debug] [ADB] Device API level: 28
[UiAutomator2] Relaxing hidden api policy
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 wait-for-device'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell echo ping'
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.settings'
[debug] [ADB] 'io.appium.settings' is installed
[debug] [ADB] Getting package info for 'io.appium.settings'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.settings'
[debug] [ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('3.2.1' >= '3.2.1')
[debug] [ADB] There is no need to install/upgrade '/usr/local/lib/node_modules/appium/node_modules/_io.appium.settings@3.2.1@io.appium.settings/apks/settings_apk-debug.apk'
[debug] [ADB] Getting IDs of all 'io.appium.settings' processes
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'pgrep --help; echo $?''
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell pgrep -f \(\[\[:blank:\]\]\|\^\)io\.appium\.settings\(\[\[:blank:\]\]\|\$\)'
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell appops set io.appium.settings android:mock_location allow'
[debug] [Logcat] Starting logs capture with command: /usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 logcat -v threadtime
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to local port 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 forward tcp:8200 tcp:6790'
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] 'io.appium.uiautomator2.server' is installed
[debug] [ADB] Getting package info for 'io.appium.uiautomator2.server'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('4.17.2' >= '4.17.2')
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk
[ADB] Using 'apksigner.jar' from '/usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar'
[debug] [ADB] Starting apksigner: /usr/local/java/jdk1.8.0_77/bin/java -Xmx1024M -Xss1m -jar /usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.17.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB] 
[debug] [ADB] sha256 hash did match for 'appium-uiautomator2-server-v4.17.2.apk'
[ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk' is signed with the default certificate
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server.test'
[debug] [ADB] 'io.appium.uiautomator2.server.test' is installed
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] Starting apksigner: /usr/local/java/jdk1.8.0_77/bin/java -Xmx1024M -Xss1m -jar /usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.17.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB] 
[debug] [ADB] sha256 hash did match for 'appium-uiautomator2-server-debug-androidTest.apk'
[ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' is signed with the default certificate
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell pm list instrumentation'
[debug] [UiAutomator2] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[ADB] Adding packages ["io.appium.settings","io.appium.uiautomator2.server","io.appium.uiautomator2.server.test"] to Doze whitelist
[debug] [ADB] Got the following command chunks to execute: [["dumpsys","deviceidle","whitelist","+io.appium.settings",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server.test",";"]]
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys deviceidle whitelist +io.appium.settings ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server.test ;'
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.17.2
[UiAutomator2] Using UIAutomator2 server from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk' and test from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","977707a29807","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 74ms
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8200/wd/hub/session] with body: {"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true,"deviceUDID":"977707a29807"}],"alwaysMatch":{}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"dafa5d1c-2e1c-4074-b5ad-af08ca28a181","value":{"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true,"deviceUDID":"977707a29807"}],"alwaysMatch":{}},"sessionId":"dafa5d1c-2e1c-4074-b5ad-af08ca28a181"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/wd/hub/session/dafa5d1c-2e1c-4074-b5ad-af08ca28a181/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"dafa5d1c-2e1c-4074-b5ad-af08ca28a181","value":{"androidId":"3e625d2c8958859e","apiVersion":"28","bluetooth":{"state":"OFF"},"brand":"Xiaomi","carrierName":"","displayDensity":320,"locale":"zh_CN","manufacturer":"Xiaomi","model":"Redmi 8A","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":1048576,"linkUpstreamBandwidthKbps":1048576,"networkCapabilities":"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED","signalStrength":-57,"transportTypes":"TRANSPORT_WIFI"},"detailedState":"CONNECTED","extraInfo":null,"isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":0,"subtypeName":"","type":1,"typeName":"WIFI"}],"platformVersion":"9","realDisplaySize":"720x1520","timeZone":"Asia/Shanghai"}}
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity and waiting for 'com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am start -W -n com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8200/wd/hub/session/dafa5d1c-2e1c-4074-b5ad-af08ca28a181/appium/device/pixel_ratio] with no body
[WD Proxy] socket hang up
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[debug] [WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/dafa5d1c-2e1c-4074-b5ad-af08ca28a181] with no body
[WD Proxy] socket hang up
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am force-stop com.app_qa'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200 
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 forward --remove tcp:8200'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1610551933449 (08:32:13 GMT-0700 (Mountain Standard Time))
[debug] [W3C] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
[debug] [W3C]     at UIA2Proxy.command (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@7.4.1@appium-base-driver/lib/jsonwp-proxy/proxy.js:275:13)
[debug] [W3C]     at processTicksAndRejections (node:internal/process/task_queues:93:5)
[debug] [W3C]     at AndroidUiautomator2Driver.commands.getDevicePixelRatio (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/commands/viewport.js:14:10)
[debug] [W3C]     at AndroidUiautomator2Driver.fillDeviceDetails (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:239:28)
[debug] [W3C]     at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:225:7)
[debug] [W3C]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] <-- POST /wd/hub/session 500 5241 ms - 1291
[HTTP] 
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:

这个错误代表了你上次自动化没正常关闭,导致它一分钟后自动关闭的时候影响了你目前的自动化。appium启动的时候加个–session-override好了

思寒大佬 还是不行:

root@ubuntu:~/Desktop/auto-test/app_ui_framework/test_case# appium --session-override
[Appium] Welcome to Appium v1.20.0
[Appium] Non-default server args:
[Appium]   sessionOverride: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: 8ac9b7d4-8adb-477a-8401-1cab4d76a697
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]},"desiredCapabilities":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},null,{"firstMatch":[{"platformName":"android","appium:deviceName":"977707a29807","appium:appPackage":"com.app_qa","appium:appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","appium:dontStopAppOnReset":false,"appium:newCommandTimeout":6000,"appium:noReset":true}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1610601631187 (22:20:31 GMT-0700 (Mountain Standard Time))
[Appium] 
[Appium] ======================================================================
[Appium]   DEPRECATION WARNING:
[Appium] 
[Appium]   The 'automationName' capability was not provided in the desired 
[Appium]   capabilities for this Android session
[Appium] 
[Appium]   Setting 'automationName=UiAutomator2' by default and using the 
[Appium]   UiAutomator2 Driver
[Appium] 
[Appium]   The next major version of Appium (2.x) will **require** the 
[Appium]   'automationName' capability to be set for all sessions on all 
[Appium]   platforms
[Appium] 
[Appium]   In previous versions (Appium <= 1.13.x), the default was 
[Appium]   'automationName=UiAutomator1'
[Appium] 
[Appium]   If you wish to use that automation instead of UiAutomator2, please 
[Appium]   add 'automationName=UiAutomator1' to your desired capabilities
[Appium] 
[Appium]   For more information about drivers, please visit 
[Appium]   http://appium.io/docs/en/about-appium/intro/ and explore the 
[Appium]   'Drivers' menu
[Appium] 
[Appium] ======================================================================
[Appium] 
[Appium] Appium v1.20.0 creating new AndroidUiautomator2Driver (v1.61.0) session
[debug] [Appium] There are no active sessions for cleanup
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "android",
[debug] [BaseDriver]     "appium:deviceName": "977707a29807",
[debug] [BaseDriver]     "appium:appPackage": "com.app_qa",
[debug] [BaseDriver]     "appium:appActivity": "com.wisdom_dyeing_fe_rn_demo_pre.MainActivity",
[debug] [BaseDriver]     "appium:dontStopAppOnReset": false,
[debug] [BaseDriver]     "appium:newCommandTimeout": 6000,
[debug] [BaseDriver]     "appium:noReset": true
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 598545c1-2e12-4c9d-84aa-b972b066fe12
[UiAutomator2] Starting 'com.app_qa' directly on the device
[ADB] Found 3 'build-tools' folders under '/usr/local/android-sdk-linux' (newest first):
[ADB]     /usr/local/android-sdk-linux/build-tools/29.0.3
[ADB]     /usr/local/android-sdk-linux/build-tools/29.0.0
[ADB]     /usr/local/android-sdk-linux/build-tools/28.0.0
[ADB] Using 'adb' from '/usr/local/android-sdk-linux/platform-tools/adb'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 start-server'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices
[debug] [ADB] Connected devices: [{"udid":"977707a29807","state":"device"}]
[AndroidDriver] Using device: 977707a29807
[ADB] Using 'adb' from '/usr/local/android-sdk-linux/platform-tools/adb'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 start-server'
[debug] [ADB] Setting device id to 977707a29807
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Getting device platform version
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 9
[debug] [ADB] Device API level: 28
[UiAutomator2] Relaxing hidden api policy
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 wait-for-device'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell echo ping'
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.settings'
[debug] [ADB] 'io.appium.settings' is installed
[debug] [ADB] Getting package info for 'io.appium.settings'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.settings'
[debug] [ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('3.2.1' >= '3.2.1')
[debug] [ADB] There is no need to install/upgrade '/usr/local/lib/node_modules/appium/node_modules/_io.appium.settings@3.2.1@io.appium.settings/apks/settings_apk-debug.apk'
[debug] [ADB] Getting IDs of all 'io.appium.settings' processes
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'pgrep --help; echo $?''
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell pgrep -f \(\[\[:blank:\]\]\|\^\)io\.appium\.settings\(\[\[:blank:\]\]\|\$\)'
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell appops set io.appium.settings android:mock_location allow'
[debug] [Logcat] Starting logs capture with command: /usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 logcat -v threadtime
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to local port 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 forward tcp:8200 tcp:6790'
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] 'io.appium.uiautomator2.server' is installed
[debug] [ADB] Getting package info for 'io.appium.uiautomator2.server'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server'
[debug] [ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('4.17.2' >= '4.17.2')
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk
[ADB] Using 'apksigner.jar' from '/usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar'
[debug] [ADB] Starting apksigner: /usr/local/java/jdk1.8.0_77/bin/java -Xmx1024M -Xss1m -jar /usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.17.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB] 
[debug] [ADB] sha256 hash did match for 'appium-uiautomator2-server-v4.17.2.apk'
[ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk' is signed with the default certificate
[debug] [ADB] Getting install status for io.appium.uiautomator2.server.test
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys package io.appium.uiautomator2.server.test'
[debug] [ADB] 'io.appium.uiautomator2.server.test' is installed
[debug] [ADB] Checking app cert for /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] Starting apksigner: /usr/local/java/jdk1.8.0_77/bin/java -Xmx1024M -Xss1m -jar /usr/local/android-sdk-linux/build-tools/29.0.3/lib/apksigner.jar verify --print-certs /usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server\@4.17.2\@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[debug] [ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[debug] [ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[debug] [ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[debug] [ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[debug] [ADB] 
[debug] [ADB] sha256 hash did match for 'appium-uiautomator2-server-debug-androidTest.apk'
[ADB] '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' is signed with the default certificate
[UiAutomator2] Server packages are not going to be (re)installed
[debug] [UiAutomator2] Waiting up to 30000ms for services to be available
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell pm list instrumentation'
[debug] [UiAutomator2] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[ADB] Adding packages ["io.appium.settings","io.appium.uiautomator2.server","io.appium.uiautomator2.server.test"] to Doze whitelist
[debug] [ADB] Got the following command chunks to execute: [["dumpsys","deviceidle","whitelist","+io.appium.settings",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server.test",";"]]
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys deviceidle whitelist +io.appium.settings ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server.test ;'
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.17.2
[UiAutomator2] Using UIAutomator2 server from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.2.apk' and test from '/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-server@4.17.2@appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","977707a29807","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 86ms
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8200/wd/hub/session] with body: {"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true,"deviceUDID":"977707a29807"}],"alwaysMatch":{}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"37addce9-2d49-400a-8351-8742eb8ac2e3","value":{"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true},"platformName":"android","deviceName":"977707a29807","appPackage":"com.app_qa","appActivity":"com.wisdom_dyeing_fe_rn_demo_pre.MainActivity","dontStopAppOnReset":false,"newCommandTimeout":6000,"noReset":true,"deviceUDID":"977707a29807"}],"alwaysMatch":{}},"sessionId":"37addce9-2d49-400a-8351-8742eb8ac2e3"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/wd/hub/session/37addce9-2d49-400a-8351-8742eb8ac2e3/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"37addce9-2d49-400a-8351-8742eb8ac2e3","value":{"androidId":"3e625d2c8958859e","apiVersion":"28","bluetooth":{"state":"OFF"},"brand":"Xiaomi","carrierName":"","displayDensity":320,"locale":"zh_CN","manufacturer":"Xiaomi","model":"Redmi 8A","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":1048576,"linkUpstreamBandwidthKbps":1048576,"networkCapabilities":"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED","signalStrength":-45,"transportTypes":"TRANSPORT_WIFI"},"detailedState":"CONNECTED","extraInfo":null,"isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":0,"subtypeName":"","type":1,"typeName":"WIFI"}],"platformVersion":"9","realDisplaySize":"720x1520","timeZone":"Asia/Shanghai"}}
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity and waiting for 'com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity'
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am start -W -n com.app_qa/com.wisdom_dyeing_fe_rn_demo_pre.MainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[debug] [WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8200/wd/hub/session/37addce9-2d49-400a-8351-8742eb8ac2e3/appium/device/pixel_ratio] with no body
[WD Proxy] socket hang up
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[debug] [WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/37addce9-2d49-400a-8351-8742eb8ac2e3] with no body
[WD Proxy] socket hang up
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell am force-stop com.app_qa'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200 
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 forward --remove tcp:8200'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running '/usr/local/android-sdk-linux/platform-tools/adb -P 5037 -s 977707a29807 shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy''
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1610601636400 (22:20:36 GMT-0700 (Mountain Standard Time))
[debug] [W3C] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
[debug] [W3C]     at UIA2Proxy.command (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@7.4.1@appium-base-driver/lib/jsonwp-proxy/proxy.js:275:13)
[debug] [W3C]     at processTicksAndRejections (node:internal/process/task_queues:93:5)
[debug] [W3C]     at AndroidUiautomator2Driver.commands.getDevicePixelRatio (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/commands/viewport.js:14:10)
[debug] [W3C]     at AndroidUiautomator2Driver.fillDeviceDetails (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:239:28)
[debug] [W3C]     at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/_appium-uiautomator2-driver@1.61.0@appium-uiautomator2-driver/lib/driver.js:225:7)
[debug] [W3C]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] <-- POST /wd/hub/session 500 5325 ms - 1291
[HTTP] 
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:

一个是之前的session关闭导致影响到你,如果你再多试几次还是这样,就查下uiautomator的日志吧,看看是什么崩溃的。用adb logcat,搜索其中的uiautomator分类的log,看下错误提示什么。

adb logcat|grep -i uiautomator

01-14 13:20:33.057  1448  2697 I ActivityManager: Force stopping io.appium.uiautomator2.server.test appid=10359 user=0: from process:10607
01-14 13:20:33.058  1448  2697 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server.test uid : 10359
01-14 13:20:33.074  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.tencent.assistant.localres.localapk.PackageChangedReceiver
01-14 13:20:33.075  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.qq.AppService.APKReceiver
01-14 13:20:33.156  9937 10611 I appium  : AppiumResponse: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
01-14 13:20:33.708  1448 11984 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: start instr
01-14 13:20:33.709  1448 11984 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:20:33.710  1448 11984 I ActivityManager: Killing 9937:io.appium.uiautomator2.server/u0a358 (adj 0): stop io.appium.uiautomato2.server: start instr
01-14 13:20:33.711  1448 11984 W ActivityManager: Crash of app io.appium.uiautomator2.server running instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner}
01-14 13:20:33.711  1448 11984 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: finished inst
01-14 13:20:33.712  1448 11984 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:20:33.712  1448 10628 I ActivityManager: Failure reporting to instrumentation watcher: comp=ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} results=Bundle[{shortMsg=Process crashed.}]
01-14 13:20:33.740  1448  1506 D Boost   : hostingType=added application, hostingName=io.appium.uiautomator2.server, callerPackage=android, isSystem=true, isBoostNeeded=false.
01-14 13:20:33.742  1448  1506 I ActivityManager: Start proc 10629:io.appium.uiautomator2.server/u0a358 for added application io.appium.uiautomator2.server caller=android
01-14 13:20:34.955 10629 10763 I TestRequestBuilder: Scanning classpath to find tests in paths [/data/app/io.appium.uiautomator2.server.test-4oNCPB0kmPgn9VKHkrPcQA==/base.apk]
01-14 13:20:35.807 10629 10763 I TestRunner: started: startServer(io.appium.uiautomator2.server.test.AppiumUiAutomator2Server)
01-14 13:20:35.815 10629 10763 I appium  : [AppiumUiAutomator2Server] Starting Server
01-14 13:20:36.921 10629 10763 I appium  : io.appium.uiautomator2.server started:
01-14 13:20:36.941 10629 10770 I appium  : Started UiAutomator2 io.appium.uiautomator2.http io.appium.uiautomator2.server on port 6790
01-14 13:25:45.768  1448  1986 I ActivityManager: Force stopping io.appium.uiautomator2.server.test appid=10359 user=0: from process:10931
01-14 13:25:45.768  1448  1986 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server.test uid : 10359
01-14 13:25:45.786  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.tencent.assistant.localres.localapk.PackageChangedReceiver
01-14 13:25:45.787  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.qq.AppService.APKReceiver
01-14 13:25:45.841 10629 10935 I appium  : AppiumResponse: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
01-14 13:25:46.401  1448  1739 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: start instr
01-14 13:25:46.401  1448  1739 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:25:46.402  1448  1739 I ActivityManager: Killing 10629:io.appium.uiautomator2.server/u0a358 (adj 0): stop io.appium.uiautomator2.server: start instr
01-14 13:25:46.403  1448  1739 W ActivityManager: Crash of app io.appium.uiautomator2.server running instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner}
01-14 13:25:46.403  1448  1739 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: finished inst
01-14 13:25:46.404  1448  1739 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:25:46.405  1448 10951 I ActivityManager: Failure reporting to instrumentation watcher: comp=ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} results=Bundle[{shortMsg=Process crashed.}]
01-14 13:25:46.438  1448  1506 D Boost   : hostingType=added application, hostingName=io.appium.uiautomator2.server, callerPackage=android, isSystem=true, isBoostNeeded=false.
01-14 13:25:46.441  1448  1506 I ActivityManager: Start proc 10952:io.appium.uiautomator2.server/u0a358 for added application io.appium.uiautomator2.server caller=android
01-14 13:25:47.648 10952 11083 I TestRequestBuilder: Scanning classpath to find tests in paths [/data/app/io.appium.uiautomator2.server.test-4oNCPB0kmPgn9VKHkrPcQA==/base.apk]
01-14 13:25:48.506 10952 11083 I TestRunner: started: startServer(io.appium.uiautomator2.server.test.AppiumUiAutomator2Server)
01-14 13:25:48.514 10952 11083 I appium  : [AppiumUiAutomator2Server] Starting Server
01-14 13:25:49.623 10952 11083 I appium  : io.appium.uiautomator2.server started:
01-14 13:25:49.636 10952 11089 I appium  : Started UiAutomator2 io.appium.uiautomator2.http io.appium.uiautomator2.server on port 6790
01-14 13:33:39.533  1448 11984 I ActivityManager: Force stopping io.appium.uiautomator2.server.test appid=10359 user=0: from process:11234
01-14 13:33:39.533  1448 11984 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server.test uid : 10359
01-14 13:33:39.542  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.tencent.assistant.localres.localapk.PackageChangedReceiver
01-14 13:33:39.542  1448  1504 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:io.appium.uiautomator2.server.test flg=0x10 (has extras) } to com.tencent.android.qqdownloader/com.qq.AppService.APKReceiver
01-14 13:33:39.625 10952 11238 I appium  : AppiumResponse: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
01-14 13:33:40.193  1448  1736 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: start instr
01-14 13:33:40.193  1448  1736 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:33:40.194  1448  1736 I ActivityManager: Killing 10952:io.appium.uiautomator2.server/u0a358 (adj 0): stop io.appium.uiautomator2.server: start instr
01-14 13:33:40.196  1448  1736 W ActivityManager: Crash of app io.appium.uiautomator2.server running instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner}
01-14 13:33:40.197  1448  1736 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10358 user=0: finished inst
01-14 13:33:40.198  1448  1736 I AutoStartManagerService: MIUILOG- Reject RestartService packageName :io.appium.uiautomator2.server uid : 10358
01-14 13:33:40.233  1448  1506 D Boost   : hostingType=added application, hostingName=io.appium.uiautomator2.server, callerPackage=android, isSystem=true, isBoostNeeded=false.
01-14 13:33:40.236  1448  1506 I ActivityManager: Start proc 11256:io.appium.uiautomator2.server/u0a358 for added application io.appium.uiautomator2.server caller=android
01-14 13:33:41.470 11256 11388 I TestRequestBuilder: Scanning classpath to find tests in paths [/data/app/io.appium.uiautomator2.server.test-4oNCPB0kmPgn9VKHkrPcQA==/base.apk]
01-14 13:33:42.325 11256 11388 I TestRunner: started: startServer(io.appium.uiautomator2.server.test.AppiumUiAutomator2Server)
01-14 13:33:42.334 11256 11388 I appium  : [AppiumUiAutomator2Server] Starting Server
01-14 13:33:43.452 11256 11388 I appium  : io.appium.uiautomator2.server started:
01-14 13:33:43.476 11256 11396 I appium  : Started UiAutomator2 io.appium.uiautomator2.http io.appium.uiautomator2.server on port 6790

找下这个日志的上下文,应该会有报错信息。

老师,我没找到,是不是我命令打错了,我学的不好,劳烦老师啦 :pray:

root@ubuntu:~/Desktop/auto-test/app_ui_framework/test_case# adb logcat|grep -C 100 Crash of app io.appium.uiautomator2.server
grep: of: No such file or directory
grep: app: No such file or directory
grep: io.appium.uiautomator2.server: No such file or directory