Appium Maven Dependency: Setup with Eclipse Project Example

โšก Smart Summary

Appium Maven dependency management lets a mobile automation project declare the java-client artifact in pom.xml, so Maven resolves every jar automatically and the same build runs on any machine without manual downloads.

  • ๐Ÿ”ด What Maven does: Apache Maven manages the build lifecycle and resolves dependencies from a single declarative pom.xml file.
  • โ˜‘๏ธ One artifact: The io.appium java-client dependency pulls in the Selenium API, remote driver and support jars transitively.
  • โœ… Version discipline: Match the java-client release to the Selenium range it declares to avoid NoSuchMethodError at run time.
  • ๐Ÿงช Fixed layout: Surefire executes only the classes under src/test/java, so misplaced tests compile but never run.
  • ๐Ÿ› ๏ธ Command line: mvn clean test compiles and executes the suite, writing results to target/surefire-reports.
  • ๐Ÿ“Š Prerequisites: Maven never starts the Appium server or a device, so both must be ready before the build begins.

Appium Maven dependency setup with pom.xml and the java-client artifact

What is Apache Maven?

Apache Maven is a Java-based project management and automation tool. It provides a multitasking framework for developers to ease the complete build lifecycle for Java applications. Maven is pre-defined and declared in an XML format called POM (Project Object Model) and referred to as โ€˜pom.xml.โ€™ It can also be used for other languages like C#, Scala, Ruby, etc.

Using the Maven framework, you can easily manage the following tasks in any project:

  • Build cycle
  • Project Documentation
  • Report Checks
  • Scrums management
  • Release Information

Basic uses of Maven are:

  • Enforces a standard directory structure.
  • Provide a reusable and easy to maintain project structure.
  • Resolve packages dependencies.
  • Provide a configuration management framework.

That dependency-resolution ability is exactly what an Appium project needs, because the Java client pulls in a chain of Selenium jars that nobody wants to download by hand.

Download Appium Maven Dependencies

Before you start writing an Appium dependency test with Maven, you need to download the Appium Maven dependency โ€” the Appium JAR download file โ€” from the Maven central repository website. The screenshot below shows the java-client artifact listing on Maven Central, where every published version and its ready-made snippet are available.

Appium java-client artifact listing on the Maven central repository search page

Or directly add the POM.xml artifact mentioned below:

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>3.4.1</version>
</dependency>

โš ๏ธ Version note: the 3.4.1 coordinate above is the original example and still shows the correct shape of the block. It predates the W3C WebDriver protocol, so a new project should raise the version. At the time of writing, the current release on Maven Central is 10.1.1, which requires Selenium 4.42.0 or later.

<dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>10.1.1</version>
</dependency>

Please go through our Maven tutorial to learn how to configure Maven with Eclipse.

Appium Maven Project Structure and Required Dependencies

Maven imposes a fixed layout, and knowing it prevents most of the confusion that follows later in this walkthrough. A generated project contains four locations that matter:

  • pom.xml โ€” the Project Object Model at the project root, where every dependency and plugin is declared.
  • src/main/java โ€” application and helper classes.
  • src/test/java โ€” test classes, and the only directory the Surefire plugin scans when you run a build.
  • target โ€” compiled output and test reports, regenerated on every build.

The Appium java-client is the only mandatory dependency, because it declares the Selenium API, remote-driver and support artifacts transitively. Many teams still pin Selenium explicitly so the version is visible in one place, and add a test runner:

<dependencies>
  <dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>10.1.1</version>
  </dependency>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.42.0</version>
  </dependency>
</dependencies>

Keep the two versions compatible. A java-client release states the Selenium range it supports, and mixing an old client with a much newer Selenium is the most common cause of a NoSuchMethodError at run time. The java-client repository documents the pairing for every release.

Testing Application with Appium and Maven

With the dependency in place, the Eclipse workflow below builds a runnable project from scratch. After configuring the Appium Java Maven plug-in in Eclipse, the workspace is ready to test any Android .apk application with Appium and Maven, as shown in the Appium Maven project example below.

Step 1) In this step,

  1. Go to NEW >> select Maven project
  2. Click on the โ€˜nextโ€™ button

The new-project wizard opens with Maven Project highlighted, as shown here.

Eclipse New Project wizard with Maven Project selected

Step 2) Then in the โ€˜New Maven Projectโ€™ window, enter โ€˜Appium Testโ€™ in the Group Id and Artifact Id columns. In this step, you have to enter:

  1. Group Id
  2. Artifact Id
  3. Version
  4. Packaging
  5. Name and Description
  6. Finish

The completed New Maven Project form looks like the screenshot below.

New Maven Project window with Group Id, Artifact Id, Version and Packaging filled in

Clicking the Finish button will open a new class under the defined Group Id (AppiumTest) name.

Step 3) To start with the Appium script, right click on โ€˜src/main/javaโ€™ in the left-side explorer window. Then select New >> class. Write the Appium code inside the selected class.

The context menu used to create that class is shown below.

Right-click menu on src/main/java showing New and Class in the Eclipse explorer

Step 4) In the same project, click on pom.xml in the left explorer menu. All dependencies will be visible by default in the โ€˜pom.xmlโ€™ tab. Refer to the image below.

pom.xml editor tab in Eclipse listing the resolved project dependencies

If the default pom.xml does not exist, then just add all the Maven Appium dependencies, extracted from the Maven central repository website:

https://central.sonatype.com/artifact/io.appium/java-client

The edited pom.xml with the Appium dependencies added is shown below.

pom.xml source view after the Appium java-client dependency has been pasted in

Step 5) Now, right click on โ€˜pom.xmlโ€™ in the left explorer, or on the XML code for the โ€˜AppiumTestโ€™ project. Then click the โ€˜Run As >> Maven Cleanโ€™ option, as shown below.

Eclipse Run As submenu with the Maven Clean option highlighted

While running, you can see all the Maven-related jar files and a success message, as in the console output below. This is how you run an Appium Java client Maven dependency test in a Maven-configured environment.

Eclipse console showing the downloaded Maven jar files and the build success message

How to Run Appium Tests with Maven Commands

The Eclipse menu is convenient, but the same build has to run unattended on a build server, and there the command line is the only option. Open a terminal in the folder that holds pom.xml and use these commands.

mvn clean
mvn clean test
mvn clean install
mvn test -Dtest=LoginTest

Each one has a distinct job:

  • mvn clean deletes the target directory so nothing stale survives into the next build. This is the command the Eclipse walkthrough above triggers.
  • mvn clean test compiles the project and executes the test classes. The Maven Surefire plugin picks them up automatically from src/test/java, using the default include patterns Test*.java, *Test.java, *Tests.java and *TestCase.java.
  • mvn clean install runs the tests and then places the packaged artifact into your local repository, so another project can depend on it.
  • mvn test -Dtest=LoginTest narrows the run to a single class while you debug.

Two points catch people out. First, the Appium server must already be running and a device or emulator must be connected before the build starts, because Maven does not launch either one โ€” verify the device with an adb check first. Second, results are written to target/surefire-reports, which is the folder a CI job should archive. The Surefire usage guide covers the configuration options in detail, and the same commands drive an Appium suite from Jenkins.

Common Appium Maven Errors and How to Fix Them

Most failures in an Appium Maven setup come from a handful of repeatable causes rather than from the test code itself. The table below maps each symptom to its usual fix.

Symptom Likely cause Fix
Could not resolve dependencies for io.appium:java-client Wrong version string, or no network access to Maven Central Copy the coordinate straight from the Maven Central listing and re-run the build
NoSuchMethodError or NoClassDefFoundError from a Selenium class java-client and selenium-java versions are incompatible Match the Selenium version to the range the java-client release declares
Tests compile but none run Test classes sit in src/main/java, or the class name does not match a Surefire include pattern Move them to src/test/java and name the class so it ends in Test
Connection refused on port 4723 The Appium server is not running Start the Appium server before the build
Invalid or unsupported capability Legacy capability names used with a modern driver Review the current desired capabilities for your platform
Unsupported class file major version The JDK used by Maven differs from the compiler level in pom.xml Align the maven.compiler.source and target properties with your installed JDK

When a build fails, read the first error Maven prints rather than the last. The later lines are usually consequences of the first missing artifact.

FAQs

Take the newest release listed on Maven Central rather than a version copied from an old tutorial. At the time of writing that is 10.1.1, which expects Selenium 4.42.0 or later on the classpath.

Machine learning models repair element locators after a UI change, group duplicate failures across devices, and predict which tests a commit is likely to break, so a shorter Maven run covers the risky area.

Copilot completes the groupId, artifactId and version elements from a one-line comment. It often suggests a stale version number, so confirm the coordinate against Maven Central before committing the file.

Not strictly. The java-client declares the Selenium artifacts transitively. Many teams still pin selenium-java explicitly so the version is visible and upgrades are deliberate rather than accidental.

Both resolve the same artifacts. Maven uses declarative XML and suits teams that want a fixed lifecycle. Gradle scripts in Groovy or Kotlin and builds incrementally, which helps on large multi-module repositories.

In src/test/java. Surefire only scans that directory during a build, so a class left in src/main/java compiles but never executes, which looks like a silently passing suite.

No. Maven resolves jars and runs tests only. Start the Appium server and connect a device or emulator first, or launch the server from your test setup method or a CI pipeline step.

Check out the repository, start the Appium server and a device, then run mvn clean test. Archive target/surefire-reports as the build artifact so failures stay readable after the agent is destroyed.

Summarize this post with: