Make an Android custom view and publish it. (Part 2)

In this part, I will demostrate how to publish the custom view so that other developers can use it by just simply adding dependency like this:

dependencies {
    compile 'com.dualcores.swagpoints:swagpoints:1.0.2'

Here we go:

1. Sign in/Register at distribution service.

Here what I used for distribution service is JFrog Bintray. Register a account if you don’t have. I will use Bintray as example, the UI may be different when you see this post!!


2. Go to profile page to create a repository, package and version:

The repository is the place to host your several projects. You can choose any repository name whatever you what, it doesn’t matter for other developer.

螢幕快照 2016-11-26 下午10.59.45

Inside the new repository, you can create a package, that is the place to host your project. You can import your projects from Github.

螢幕快照 2016-11-26 下午11.05.54

For each package, you can create several versions, again, you can choose whatever name you want, not restricted to the traditional version number major.minor.patch rule.

螢幕快照 2016-11-27 上午8.45.54

3. Generate and upload aar files:

We use gradle to do this job, here I use this library to help

Open you library module gradle file, add the following code snippet to buttom of module build.gradle file:

// or use the remote copy to keep update with latest changes
apply from: ''

and JCenter configuration:

ext {
    PUBLISH_GROUP_ID = 'com.dualcores.swagpoints'
    PUBLISH_ARTIFACT_ID = 'swagpoints'
    PUBLISH_VERSION = '1.0.0'
螢幕快照 2016-11-27 上午9.02.37
The two place you have to insert code in library module build.gradle file

Then sync your project and open your terminal, go to your project root path, execute the command:

./gradlew clean build generateRelease

If success, you will see the result in you terminal and you can upload the zip file from PROJECT_ROOT/library/build/release/1.0.0:

螢幕快照 2016-11-27 上午9.12.13

4. Add to JCenter:

Go back to your project page in bintray, there will be a Add to JCenter button in right-hand column, just click it to fill out a message and wait to be accepted. It takes hours or several days to be accepted, just be patient. This step is required so that to make your project downloadable and discoverable by gradle dependencies.

螢幕快照 2016-11-27 上午9.20.19

5. Wait for acception and test it.

You will receive an email to inform you that your Add to JCenter request is accepted.

螢幕快照 2016-11-27 上午9.29.57

Once it is accepted, test if gradle dependency works well by adding the dependency to sample module and sync. If it builds successfully, congratulation!!!! You’ve done. Good job~

compile 'com.dualcores.swagpoints:swagpoints:1.0.0'

The version may change when you try to use it, just check my Github to get the latest version and give the project a star.


Happy coding!!

6 thoughts on “Make an Android custom view and publish it. (Part 2)

Add yours

  1. Hi,
    Thanks for the great tutorial!
    For some reason I followed the tutorial, but I don’t get the “Add to Jcenter” button, it is not showing up..
    Any idea?

    1. Did you upload your artifacts successfully? Make sure that there are some artifacts so that it can be published.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑