Guide to publishing your Android Library via MavenCentral

If you come from the java world, you would already be knowing about MavenCentral in a big way. MavenCentral is the central repository which hosts all the maven artifacts and one can reference them from anywhere in the world. Android artifacts can also be hosted on MavenCentral in a similar manner. Here I am going to document the process to publish an android library to MavenCentral, as I followed it.

This post is second in parts of a series. If you didnot read the others in series , go have a look

  1. Guide to publishing your Android Library via Jcenter/Bintray
  2. Guide to publishing your Android Library via MavenCentral
  3. Guide to publishing your Android Library via JitPack

The first step need you to create and build your Android “Awesome” Library and can be read in the first post of this series here. If you have not done so , then please go ahead and read it up.

Assuming you already have your Android “Awesome” Library built , I will jump directly to steps involved in publishing your library to MavenCentral

Publishing your Android “Awesome” Library

Setup GPG and generate yourself a key.

  • Now list your gpg keys
  $ gpg --list-keys

There the first line will be like pub XXXXX/YYYYYYYY . Remember that ‘YYYYYYYY’ part, it’s you key ID.

  • Next, publish your keys
  $ gpg --keyserver hkp:// --send-keys YYYYYYYY
  $ gpg --keyserver hkp:// --send-keys YYYYYYYY
  • To ensure your keys were published
  $ gpg --keyserver hkp:// --search-keys # Use your email

Setup Sonatype account

and Login login

  • Once you are logged in, create a new issue create

  • Fill out the form as below



  • Next hit Create. After that, it can take up to 2 business days to process your issue. Then you will receive a confirmation that your configuration has been prepared and you can publish your library.

    IMPORTANT : Do not deploy until after you have received an e-mail notice indicating that the ticket is Resolved.


  • Update on your local machine at location ~/.gradle/ and include


IMPORTANT: Steps for setting up your sonatype account up till here are required only once. The steps after these are required whenever publishing your android library, even if its a new one. Just remember to configure it well in your

Add the plugin by Chris Banes to your library’s build.gradle.

NOTE: Below is a fork of the original script written by Chris Banes.

apply from: ''

and define the required variables in the

# Properties used by gradle maven-push plugin

  • Run in terminal to publish your artifacts
  ./gradlew build clean uploadArchive




  1. Close the staged artifact.[wait]

  2. Release the closed artifact (keep drop artifact selected).[wait]

  3. Wait for some hours before everything gets synced with MavenCentral.

Using your Android “Awesome” Library in other projects

Your code is available through MavenCentral if you have received the mail with confirmation

You can use the lib now as follows

dependencies {
    compile '<group_name>:<artifact_name>:1.0'

i.e for the sample lib in this repo , awesomelib

dependencies {
      compile 'com.github.nisrulz:awesomelib:1.0'
  • Let the world know of your AwesomeLib
  • Add a readme that explains how to integrate and use your Awesome library
  • Add a license block as in this repo
  • Also include a badge of MavenCentral in your readme
  • Promote your lib on social media so that others can know about it.
  • Always add a working sample app in your project that demonstrates your library in use.
  • Add screenshots if possible in your readme.

The code for the AwesomeLibrary and this guide itself is open sourced and available on github

Star it or just fork it to use it.

Nishant Srivastava

Creative sleeper. Avid dreamer.

Berlin, Germany