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

在IntelliJ中启动Appium时触发NullPointerException问题

Appium启动时触发NullPointerException异常

问题描述

在IntelliJ中启动Appium时抛出NullPointerException,异常触发在Baseclass的appiumStart方法中创建AppiumServiceBuilder实例的代码行。

pom.xml依赖配置

<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>8.5.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.14.3</version>
  <scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.11.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-support</artifactId>
  <version>4.11.0</version>
</dependency>

Baseclass核心代码

AppiumDriverLocalService service;

public void appiumStart(){
        service = new AppiumServiceBuilder().withAppiumJS(new File("//usr//local//lib//node_modules//appium//build//lib//main.js")).withIPAddress("127.0.0.1").usingPort(4724).build();
        service.start();
}

异常触发代码行

service = new AppiumServiceBuilder().withAppiumJS(new File("//usr//local//lib//node_modules//appium//build//lib//main.js")).withIPAddress("127.0.0.1").usingPort(4724).build();

使用的环境版本

  • Appium: 2.1.3
  • Node: v16.15.1
  • NPM: 8.11.0
  • Java: 1.8
  • Java-client: 8.5.1

已尝试操作

  • 更换Appium和java-client版本,问题未解决
  • 确认main.js文件路径存在

内容的提问来源于stack exchange,提问作者Ganesan M

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 08:52:27