You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Maestro为Flutter应用执行UI测试时遭遇java.lang.NoSuchMethodError错误

解决Maestro UI测试报错:java.lang.NoSuchMethodError: java.io.InputStream.readAllBytes()[B

问题现象

执行Maestro测试命令:

i@is-MacBook-Pro samples % maestro test android-flow.yaml

出现如下错误:

Exception in thread "main" java.lang.NoSuchMethodError: java.io.InputStream.readAllBytes()[B
    at maestro.cli.device.ios.Simctl.list(Simctl.kt:14)
    at maestro.cli.device.DeviceService.listIOSDevices(DeviceService.kt:164)
    at maestro.cli.device.DeviceService.listDevices(DeviceService.kt:124)
    at maestro.cli.device.DeviceService.listConnectedDevices(DeviceService.kt:114)
    at maestro.cli.device.PickDeviceInteractor.pickDeviceInternal(PickDeviceInteractor.kt:33)
    at maestro.cli.device.PickDeviceInteractor.pickDevice(PickDeviceInteractor.kt:14)
    at maestro.cli.util.MaestroFactory.createMaestro(MaestroFactory.kt:35)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:63)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:31)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
    at picocli.CommandLine.access$1200(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
    at picocli.CommandLine.execute(CommandLine.java:2058)
    at maestro.cli.AppKt.main(App.kt:97)

问题原因

java.io.InputStream.readAllBytes()是Java 9及以上版本才新增的方法,当前运行Maestro的JDK版本低于Java 9,导致方法找不到。

解决方案

  1. 检查当前JDK版本:

    java -version
    

    若输出显示版本为Java 8(1.8.x)或更低,需升级JDK。

  2. 升级JDK至Java 9及以上版本:
    安装OpenJDK或Oracle JDK,确保系统环境变量JAVA_HOME指向新版本JDK路径。

  3. 验证升级并重新测试:
    再次运行java -version确认版本符合要求,然后重新执行测试命令:

    maestro test android-flow.yaml
    

内容的提问来源于stack exchange,提问作者Ilyos Yuldoshev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 09:50:32