Publish an Android library on jCenter

4 min readDec 30, 2016

How can you publish your Android library on jCenter, so that everyone can use it? There may be other posts explaining this, but most of them use an additional script, while it's actually easy to do without!

Setup your Android library project

It's important that your Android project has the right structure. You should create a new Phone & tablet project in Android Studio. Then you add a Module, which will be your library, by right clicking in Android Studio on your app.

Now you Choose Android Library.

After finishing the wizard, you now have an Android Studio project containing an Android App and an Android Library. The app can make direct use of the library. It’s a good practice to use this app as a demonstration on how to use this library. Certainly for open source projects!

In the dependencies list of the app, you add the library by:

dependencies {
compile project(':library-module-name')

With the project correctly setup, the library made, let’s move on to publishing it to jCenter!

Get a Bintray account!

If you don’t have already, create yourself a Bintray account. This account is used to publish the library inside of a maven repository. If your library is part of a company or organisation, it makes sense to also create a Bintray organisation.

Create a Maven repository

Inside your organisation or user account, create your first repository.

Choose Add New Repository.

  1. Name: This name is not very important, could either be as simple as maven or part of your group id like be.createweb
  2. Type: Maven
  3. License

Create a GPG key

You best use a GPG (public/private) key to sign your library. After creating this key you ether add upload this to your profile settings, or the organisation settings, depending where the library will be published. I’ll link to this Github Help page, to create your GPG key. Do use a passphrase!

Project changes (global)

Definitely when your Android library project is open source, and published on for example Github, you don’t want to put your GPG passphrase and bintray api key in your project. Instead, you add the sensitive values in your global

bintray_user=your bintray user
bintray_organisation= your bintray organisation
bintray_apikey=your bintray api key
bintray_gpg_passphrase=your gpg passphrase (project root)

Following is an example of the file for the project. It contains your application and group id, the libraries version number and code, a short description, some urls to Github. These are needed for the Bintray publication.


libDescription=Android library to scan for iBeacons.

build.gradle (project root)

plugins {
id “com.jfrog.bintray” version “1.7.2” // jCenter
id “” version “1.5” // maven

build.gradle (library module)

apply plugin: ''
apply plugin: 'com.jfrog.bintray'
apply plugin: ''
// for Bintray
def projectVersionCodeNr = Integer.parseInt(projectVersionCode);
def libGit = libGit;
def libUrl = libUrl;
def libDescription = libDescription
def libGroupId = libGroupId;
def libArtifactId = libArtifactId;

// for Maven
group = libGroupId
version = projectVersionName
install {
repositories.mavenInstaller {
pom.project {
name libArtifactId
description libDescription
url libUrl
inceptionYear '2016'

packaging 'aar'
groupId libGroupId
artifactId libArtifactId
version projectVersionName

licenses {
license {
name 'MIT'
url libLicenseUrl

bintray {
user = bintray_user
key = bintray_apikey
pkg {
repo = libGroupId
name = libArtifactId
userOrg = bintray_user_org
licenses = ['MIT']
vcsUrl = libGit
version {
name = projectVersionName
gpg {
sign = true
passphrase = bintray_gpg_phrase
configurations = ['archives']

Publish to Bintray!

Now that your library is correctly setup, it’s time to push it to Bintray. The following Gradle commands will prepare your release and then push the files to Bintray.

./gradlew :library-module-name:clean
./gradlew :library-module-name:assembleRelease
./gradlew :library-module-name:bintrayUpload

When everything went well you should be able to see the files on Bintray:

You can now confirm it by clicking Publish!

Add on jCenter

With your first version published to Bintray, this is the perfect moment to request that your library is also available through jCenter.

On your general page of your library on Bintray, you'll see a link Add to jCenter next to Linked to. Click it, add a little description for Bintray why they should add your library to jCenter. Usually, after a few hours, they will approve your request, and at last, everyone can make use of your library through jCenter!




React Native + Android | 🏄‍♂️ kitesurfer | 🌊 ocean addict | 💗 open source | 🌍 climate