Whilst building a demo application showcasing google AutoService, I encountered the below error:


Searching through the internet, most solutions recommended upgrading the Google Guava version but that did not resolve the problem.

The main cause of this error, was putting the wrong Autoservice dependency in the classpath.

If your POM file has the below dependency, then you are most likely get this error.


In this guide, you will solve the compilation error when using AutoService on a maven project.

When you’re finished, you’ll be able to build jar files with the right META-INF/services information.


Before you begin this guide you’ll need:

Step 1 — Check what is in your dependency tree

We need to establish what we have in our dependency tree, because maven might be pulling in a version of the jar as a transitive dependency which might not work with your project

Run the following command to see the jar file in your tree:

$ mvn dependency:tree

if the below are missing then follow step 2;<version>:compile<version>:compile

Step 2 — Add AutoService Annotation Dependency to POM file

Add the following compile-time dependency to your classpath so the project can compile and pull in the relevant classes.


Run the below to ensure your project compiles:

$ mvn clean compile

Now run the package command to generate the jar file in your target directory

mvn clean package

Spy the content of the Jar file to view the generated AutoService metadata

$  jar tf target/<jar-filename>.jar | grep META-INF/services/

You should not get any results.

Developers sometimes, forget to include the right metadata instructions when creating the jar file and maven will not raise any error. This is the exact problem Autoservice solves for us, removing the need to tell maven of all your metadata rule.

The next step will walk you through the process of adding the processor.

Step 3 — Tell Maven to generate the Metadata

Add the following configuration to the compiler plugin


Now run the package again to generate the jar file in your target directory

mvn clean package

Spy the content of the Jar file again, to view the generated metadata

$  jar tf target/<jar-filename>.jar | grep META-INF/services/

Assuming our processor class is org.ihq.MyAutoclass, this time the output should resemble below



You’ve set up Google AutoService with Maven to autogenerate metadata without compile error(s).