appium server运行脚本时报错

1.启动Appium客户端运行脚本时时可以正常通过
2.终端输入appium,再运行脚本就报错,麻烦老师帮忙看看

版本信息:
appium: 1.20.2

脚本内容

from appium import webdriver
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['platformVersion']='6.0'
desired_caps['deviceName']='emulator-5554'
# com.android.settings/com.android.settings.Settings
desired_caps['appPackage']='com.android.settings'
desired_caps['appActivity']='com.android.settings.Settings'

driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
print("启动【设置】应用")
driver.quit()

报错信息
[Appium] Welcome to Appium v1.20.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: b82fe51b-7770-408c-a4f7-03110cab62fb
[HTTP] → POST /wd/hub/session
[HTTP] {“capabilities”:{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]},“desiredCapabilities”:{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”},null,{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]}]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1638185152337 (19:25:52 GMT+0800 (中国标准时间))
[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] Introduction - Appium and explore the
[Appium] ‘Drivers’ menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.20.2 creating new AndroidUiautomator2Driver (v1.61.2) 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:platformVersion”: “6.0”,
[debug] [BaseDriver] “appium:deviceName”: “emulator-5554”,
[debug] [BaseDriver] “appium:appPackage”: “com.android.settings”,
[debug] [BaseDriver] “appium:appActivity”: “com.android.settings.Settings”
[debug] [BaseDriver] },
[debug] [BaseDriver] “firstMatch”: [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 2c1882a2-2c45-4a67-a97b-b792d9b76bc0
[UiAutomator2] Starting ‘com.android.settings’ directly on the device
[ADB] Found 1 ‘build-tools’ folders under ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx’ (newest first):
[ADB] /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/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”:“emulator-5554”,“state”:“device”}]
[AndroidDriver] Looking for a device with Android ‘6.0.0’
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 6.0.1
[debug] [ADB] Setting device id to emulator-5554
[AndroidDriver] Using device: emulator-5554
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 start-server’
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 23
[debug] [ADB] Device API level: 23
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping’
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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 ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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/apks/settings_apk-debug.apk’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell ‘pgrep --help; echo $?’’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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] [Logcat] Starting logs capture with command: /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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 ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790’
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.4.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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 ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] The installed ‘io.appium.uiautomator2.server’ package is older than ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk’ (41 < 79 or ‘4.3.0’ < ‘4.17.4’)’
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: olderVersionInstalled
[debug] [ADB] Checking app cert for /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk
[ADB] Using ‘apksigner.jar’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar’
[debug] [ADB] Starting apksigner: ‘/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java’ -Xmx1024M -Xss1m -jar /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar verify --print-certs /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched ‘/’ to command name ‘deleteSession’
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.android.settings’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8200’
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1638185153550 (19:25:53 GMT+0800 (中国标准时间))
[debug] [W3C] Encountered internal error running command: Error: Cannot verify the signature of ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211029-21272-13ppkt0.73l8/appium-uiautomator2-server-v4.17.4.apk’. Original error: Error: A JNI error has occurred, please check your installation and try again
[debug] [W3C] Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[debug] [W3C] at java.lang.ClassLoader.defineClass1(Native Method)
[debug] [W3C] at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
[debug] [W3C] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[debug] [W3C] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
[debug] [W3C] at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
[debug] [W3C] at java.security.AccessController.doPrivileged(Native Method)
[debug] [W3C] at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[debug] [W3C] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[debug] [W3C] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
[debug] [W3C]
[debug] [W3C] at ADB.checkApkCert (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/apk-signing.js:270:11)
[debug] [W3C] at UiAutomator2Server.installServerApk (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:111:13)
[debug] [W3C] at AndroidUiautomator2Driver.initUiAutomator2Server (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:485:7)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:379:5)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:224:7)
[debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] ← POST /wd/hub/session 500 1276 ms - 3227
[HTTP]

1、看下你的java版本是不是1.8
2、看下SDK安装目录下,build-tools版本是不是低于30

java version “1.8.0_281”
build-tools 版本应该是 31.0.0

降级build-tools 版本 小于30即可,29就可以
参考帖子 Android Studio安装(推荐使用这种方法安装SDK)

老师,我把build-tools 版本降为29.0.3了,但还是报错呢
image

发下日志看看

报错是报错 但是报错的具体内容还需要具体分析 不要光看结果 要看报错的原因和具体报错的内容才能确定问题是不是变化了
之前你截图的问题 在修改版本之后应该已经解决了 新报的错误需要发一下 具体问题具体分析

来了来了
[Appium] Welcome to Appium v1.20.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: ebecde87-94c8-4236-87a6-f1430e073cbb
[HTTP] → POST /wd/hub/session
[HTTP] {“capabilities”:{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]},“desiredCapabilities”:{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{“platformName”:“Android”,“platformVersion”:“6.0”,“deviceName”:“emulator-5554”,“appPackage”:“com.android.settings”,“appActivity”:“com.android.settings.Settings”},null,{“alwaysMatch”:{“platformName”:“Android”,“appium:platformVersion”:“6.0”,“appium:deviceName”:“emulator-5554”,“appium:appPackage”:“com.android.settings”,“appium:appActivity”:“com.android.settings.Settings”},“firstMatch”:[{}]}]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1638285228588 (23:13:48 GMT+0800 (中国标准时间))
[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] Introduction - Appium and explore the
[Appium] ‘Drivers’ menu
[Appium]
[Appium] ======================================================================
[Appium]
[Appium] Appium v1.20.2 creating new AndroidUiautomator2Driver (v1.61.2) 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:platformVersion”: “6.0”,
[debug] [BaseDriver] “appium:deviceName”: “emulator-5554”,
[debug] [BaseDriver] “appium:appPackage”: “com.android.settings”,
[debug] [BaseDriver] “appium:appActivity”: “com.android.settings.Settings”
[debug] [BaseDriver] },
[debug] [BaseDriver] “firstMatch”: [
[debug] [BaseDriver] {}
[debug] [BaseDriver] ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: c84f1ae0-73b9-4d51-a948-18acd70d7455
[UiAutomator2] Starting ‘com.android.settings’ directly on the device
[ADB] Found 1 ‘build-tools’ folders under ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx’ (newest first):
[ADB] /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/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”:“emulator-5554”,“state”:“device”}]
[AndroidDriver] Looking for a device with Android ‘6.0.0’
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 6.0.1
[debug] [ADB] Setting device id to emulator-5554
[AndroidDriver] Using device: emulator-5554
[ADB] Using ‘adb’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 start-server’
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 23
[debug] [ADB] Device API level: 23
[AndroidDriver] No app sent in, not parsing package/activity
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping’
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings’
[debug] [ADB] ‘io.appium.settings’ is not installed
[debug] [ADB] App ‘/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk’ is not installed
[debug] [ADB] Installing ‘/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 help’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 features’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell ‘ls -t -1 /data/local/tmp/appium_cache 2>&1 || echo ERROR’’
[debug] [ADB] The current Android API does not support extended ls options. Defaulting to no-options call
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell ‘ls /data/local/tmp/appium_cache 2>&1 || echo ERROR’’
[debug] [ADB] Got an error ‘/data/local/tmp/appium_cache: No such file or directory’ while getting the list of files in the cache. Assuming the cache does not exist yet
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell mkdir -p /data/local/tmp/appium_cache’
[debug] [ADB] The count of applications in the cache: 0
[ADB] Caching the application at ‘/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk’ to ‘/data/local/tmp/appium_cache/f95199d4998f47493644c3dae404ba88006c3083.apk’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell mkdir -p /data/local/tmp/appium_cache’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 push /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk /data/local/tmp/appium_cache/f95199d4998f47493644c3dae404ba88006c3083.apk’
[ADB] The upload of ‘settings_apk-debug.apk’ (1.18 MB) took 125ms
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pm install -g /data/local/tmp/appium_cache/f95199d4998f47493644c3dae404ba88006c3083.apk’
[ADB] The installation of ‘settings_apk-debug.apk’ took 622ms
[debug] [ADB] Install command stdout: pkg: /data/local/tmp/appium_cache/f95199d4998f47493644c3dae404ba88006c3083.apk
[debug] [ADB] Success
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell ‘pgrep --help; echo $?’’
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’
[AndroidDriver] Granting permissions SET_ANIMATION_SCALE,CHANGE_CONFIGURATION,ACCESS_FINE_LOCATION to ‘io.appium.settings’
[debug] [ADB] Granting permissions [“android.permission.SET_ANIMATION_SCALE”,“android.permission.CHANGE_CONFIGURATION”,“android.permission.ACCESS_FINE_LOCATION”] to ‘io.appium.settings’
[debug] [ADB] Got the following command chunks to execute: [[“pm”,“grant”,“io.appium.settings”,“android.permission.SET_ANIMATION_SCALE”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.CHANGE_CONFIGURATION”,";",“pm”,“grant”,“io.appium.settings”,“android.permission.ACCESS_FINE_LOCATION”,";"]]
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE ; pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION ; pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION ;’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’
[debug] [ADB] Starting Appium Settings app
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am start -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’
[debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f ([[:blank:]]|^)io.appium.settings([[:blank:]]|$)’
[debug] [Logcat] Starting logs capture with command: /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 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 ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790’
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[UiAutomator2] Server package at ‘/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.17.4.apk’ is not writeable. Will copy it into the temporary location at ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g’ as a workaround. Consider making this file writeable manually in order to improve the performance of session startup.
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server’
[debug] [ADB] ‘io.appium.uiautomator2.server’ is not installed
[debug] [ADB] App ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g/appium-uiautomator2-server-v4.17.4.apk’ is not installed
[debug] [UiAutomator2] io.appium.uiautomator2.server installation state: notInstalled
[debug] [ADB] Checking app cert for /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g/appium-uiautomator2-server-v4.17.4.apk
[ADB] Using ‘apksigner.jar’ from ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar’
[debug] [ADB] Starting apksigner: ‘/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java’ -Xmx1024M -Xss1m -jar /Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/build-tools/30.0.0-preview/lib/apksigner.jar verify --print-certs /var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g/appium-uiautomator2-server-v4.17.4.apk
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched ‘/’ to command name ‘deleteSession’
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.android.settings’
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running ‘/Users/yangmeiqing/Library/Android/sdk/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8200’
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1638285232056 (23:13:52 GMT+0800 (中国标准时间))
[debug] [W3C] Encountered internal error running command: Error: Cannot verify the signature of ‘/var/folders/sw/p9cglktj053gx6rhx8xrd6pm0000gn/T/20211030-4052-1nprh61.rwg7g/appium-uiautomator2-server-v4.17.4.apk’. Original error: Error: A JNI error has occurred, please check your installation and try again
[debug] [W3C] Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
[debug] [W3C] at java.lang.ClassLoader.defineClass1(Native Method)
[debug] [W3C] at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
[debug] [W3C] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[debug] [W3C] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
[debug] [W3C] at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
[debug] [W3C] at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
[debug] [W3C] at java.security.AccessController.doPrivileged(Native Method)
[debug] [W3C] at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[debug] [W3C] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
[debug] [W3C] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[debug] [W3C] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
[debug] [W3C]
[debug] [W3C] at ADB.checkApkCert (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/apk-signing.js:270:11)
[debug] [W3C] at UiAutomator2Server.installServerApk (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:111:13)
[debug] [W3C] at AndroidUiautomator2Driver.initUiAutomator2Server (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:485:7)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:379:5)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:224:7)
[debug] [W3C] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:371:35)
[HTTP] ← POST /wd/hub/session 500 3537 ms - 3227
[HTTP]

image
很明显你的SDK里面还是存在30版本的build-tools

老师辛苦了,我按照帖子 Android Studio安装(推荐使用这种方法安装SDK) 修改了build-tools的版本,貌似没成功,sdk tools里显示installed的是29.0.3

可以对比一下 看看Android studio里面显示的SDK目录 跟上面截图中的SDK目录是否一致
另外再去我截图的目录看看 是不是还存在比29版本更高的目录

谢谢老师,解决了

关闭