AppCrawler远程连接手机报错:Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported

Failed控制台输出
Started by upstream project "多台安卓同时执行自动化测试" build number 27
originally caused by:
 Started by user root
Running as SYSTEM
Building remotely on demo in workspace /tmp/jenkins/workspace/多台安卓同时执行自动化测试/devices/P7CDU18929008778/label/demo
[demo] $ /bin/bash /tmp/jenkins7856922079449045202.sh
\
20211121122041_com.bs.finance
20211121122142_com.bs.finance
20211121122704_com.bs.finance
20211121123119_com.bs.finance
appcrawler-2.7.1-hogwarts.jar
demo.yaml
stf.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    88  100    58  100    30    810    419 --:--:-- --:--:-- --:--:--   816
Device P7CDU18929008778 added successfully
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   102  100   102    0     0   1660      0 --:--:-- --:--:-- --:--:--  1672
failed to authenticate to 192.168.31.103:7401
Device P7CDU18929008778 remote connected successfully
List of devices attached
192.168.31.103:7401	unauthorized

remote_device=192.168.31.103:7401
/tmp/jenkins7856922079449045202.sh:行19: remote_device#*:: 未找到命令
2021-11-21 12:34:34 INFO [AppCrawler$.76.main] 
-------------------------------------------------
appcrawler v2.7.0 全平台自动遍历测试工具
Q&A: https://ceshiren.com/c/opensource/appcrawler
author: 思寒 seveniruby@霍格沃兹测试开发学社
-------------------------------------------------

2021-11-21 12:34:34 INFO [AppCrawler$.189.parseParams] Find Conf /root/AppCrawler/demo.yaml
2021-11-21 12:34:35 INFO [AppCrawler$.218.parseParams] use appium in the config file http://127.0.0.1:4723/wd/hub
2021-11-21 12:34:35 INFO [AppCrawler$.330.addLogFile] 
-------------------------------------------------
appcrawler v2.7.0 全平台自动遍历测试工具
Q&A: https://ceshiren.com/c/opensource/appcrawler
author: 思寒 seveniruby@霍格沃兹测试开发学社
-------------------------------------------------

2021-11-21 12:34:35 INFO [AppCrawler$.333.addLogFile] result directory = 20211121123433_com.bs.finance
2021-11-21 12:34:36 INFO [Crawler.127.start] set xpath attribute with List(name(), name, label, value, resource-id, content-desc, text, id, name, innerText, tag, class)
2021-11-21 12:34:36 INFO [Crawler.131.start] set tag attribute with List(name(), name, label, resource-id, content-desc, id, name, tag, class)
2021-11-21 12:34:36 INFO [Crawler.101.$anonfun$loadPlugins$4] com.ceshiren.appcrawler.plugin.TagLimitPlugin@7927bd9f
2021-11-21 12:34:36 INFO [Crawler.101.$anonfun$loadPlugins$4] com.ceshiren.appcrawler.plugin.ReportPlugin@532721fd
2021-11-21 12:34:36 INFO [Crawler.101.$anonfun$loadPlugins$4] com.ceshiren.appcrawler.plugin.FreeMind@410954b
2021-11-21 12:34:36 INFO [Plugin.23.init] com.ceshiren.appcrawler.plugin.TagLimitPlugin init
2021-11-21 12:34:36 INFO [Plugin.23.init] com.ceshiren.appcrawler.plugin.ReportPlugin init
2021-11-21 12:34:36 INFO [Plugin.23.init] com.ceshiren.appcrawler.plugin.FreeMind init
2021-11-21 12:34:36 INFO [ReportFactory$.33.initReportPath] reportPath=/root/AppCrawler/20211121123433_com.bs.finance
2021-11-21 12:34:36 INFO [ReportFactory$.35.initReportPath] testcaseDir=/root/AppCrawler/20211121123433_com.bs.finance/tmp/
2021-11-21 12:34:36 INFO [ReportFactory$.38.initReportPath] create /root/AppCrawler/20211121123433_com.bs.finance/tmp directory
2021-11-21 12:34:36 INFO [Crawler.138.start] prepare setup Appium
2021-11-21 12:34:36 INFO [Crawler.293.setupAppium] afterAllMax=2
2021-11-21 12:34:39 INFO [Crawler.299.setupAppium] 
2021-11-21 12:34:39 INFO [Crawler.335.setupAppium] use AppiumClient
2021-11-21 12:34:39 INFO [Crawler.336.setupAppium] HashMap(appActivity -> .ui.common.WelcomeFinalActivity, udid -> 192.168.31.103:7401, appium -> http://127.0.0.1:4723/wd/hub, noReset -> true, fullReset -> false, appPackage -> com.bs.finance, systemPort -> 1)
2021-11-21 12:34:39 INFO [AppiumClient.46.<init>] Capabilities {app: , appActivity: .ui.common.WelcomeFinalActi..., appPackage: com.bs.finance, appium: http://127.0.0.1:4723/wd/hub, deviceName: demo, fullReset: false, newCommandTimeout: 120, noReset: true, systemPort: 1, udid: 192.168.31.103:7401}
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.15.2.el7.x86_64', java.version: '1.8.0_231'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
    at getResponseForW3CError (/usr/local/node-v16.13.0-linux-x64/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
    at asyncHandler (/usr/local/node-v16.13.0-linux-x64/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.15.2.el7.x86_64', java.version: '1.8.0_231'
Driver info: driver.version: AndroidDriver
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:216)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:225)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:363)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
	at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:99)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:97)
	at com.ceshiren.appcrawler.driver.AppiumClient.<init>(AppiumClient.scala:52)
	at com.ceshiren.appcrawler.core.Crawler.setupAppium(Crawler.scala:339)
	at com.ceshiren.appcrawler.core.Crawler.start(Crawler.scala:139)
	at com.ceshiren.appcrawler.AppCrawler$.startCrawl(AppCrawler.scala:323)
	at com.ceshiren.appcrawler.AppCrawler$.parseParams(AppCrawler.scala:290)
	at com.ceshiren.appcrawler.AppCrawler$.main(AppCrawler.scala:81)
	at com.ceshiren.appcrawler.AppCrawler.main(AppCrawler.scala)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:193)
	... 20 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.15.2.el7.x86_64', java.version: '1.8.0_231'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
    at getResponseForW3CError (/usr/local/node-v16.13.0-linux-x64/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
    at asyncHandler (/usr/local/node-v16.13.0-linux-x64/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
	at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
	at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
	... 25 more
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    60  100    60    0     0   1293      0 --:--:-- --:--:-- --:--:--  1304
Device P7CDU18929008778 removed successfully
adb: usage: adb disconnect [HOST[:PORT]]
Build step 'Execute shell' marked build as failure
Finished: FAILURE
#配置SDK环境
export ANDROID_HOME=/usr/local/Android/sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools

看下你的ANDROID_HOME是否有配置;
你先吧Appium环境配置完成,再去执行遍历吧

关闭