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 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.
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,
- Go to NEW >> select Maven project
- Click on the โnextโ button
The new-project wizard opens with Maven Project highlighted, as shown here.
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:
- Group Id
- Artifact Id
- Version
- Packaging
- Name and Description
- Finish
The completed New Maven Project form looks like the screenshot below.
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.
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.
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.
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.
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.
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
targetdirectory 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 patternsTest*.java,*Test.java,*Tests.javaand*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.








