As an Android developer in android development company, we use a lot of third parties libraries which are available on Github and it’s easy.It saves our time and reduces the complexity of the code.It’s fun to use.But have you ever thought of creating one for yourself? if yes, then you are at the right place.

Let’s start!

1.Create a package on Bintray

First of all. You need to create a package on bintray. To do so, you need a bintray account and create a package on the website.

  • Register for an account on bintray.com. (Follow the instructions)
Bintray signin

Bintray SignIn

  • Once registration is completed, login to the website and click on Add a new repository 
Bintray profile android library

Bintray profile

  • In repository, input name as maven(we can give any name)  and select type as maven
  • We can select license also like apache etc
  • Click on Create
creating new package in bintray

Bintray package

  • Click on Add New Package to start creating a new package for our library.
adding package in bintray

Adding new package

  • Enter all of that required information
Bintray package details

Package details

  • Although there is no rule on how to name the Package Name but there is some name convention. Just set all of the characters to lowercase and separate each word with a hyphen (-), for example, library. Once every required field is done, click on Create Package to finish.
  • The website will redirect you to Edit Package page. Click at package’s name under Edit Package text to enter package’s details page.
android library bintray

Bintray profile

  • Done! We now have our own Maven Repository on Bintray which is ready to be uploaded the library.
android library bintary

Bintray profile

2.Create an android studio project

  • Create a new project in Android studio
  • Give your project name and click finish
  • Again go to File>New>New module
module in android

Creating new module

android library

Select android library

android library name in android studio

Library name

  • Click finish
  • Now go to build.gradle(Project) and add these dependencies
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

like

dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
  • Again come to build.gradle(library) and add and modify according to your data
ext {
    bintrayRepo = 'maven'
    bintrayName = 'LogR'

    publishedGroupId = 'com.colorssoftware.library' //this is GROUPID
    libraryName = 'library' //this is your library name
    artifact = 'library' //this is ARTIFACTID

    libraryDescription = 'A login and registration library for android'

    siteUrl = 'https://github.com/ColorsSoftwarePvtLtd/Framework-Android'
    gitUrl = 'https://github.com/ColorsSoftwarePvtLtd/Framework-Android.git'

    libraryVersion = '1.0.0' //this is version name

    developerId = 'braj24'
    developerName = 'Braj Bhushan Singh'
    developerEmail = 'braj.nmit@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}
  • then add this at the bottom
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

We will discuss something about ARTIFACT_ID, GROUP_ID and VERSION

Let’s take one famous library, Picasso

compile 'com.squareup.picasso:picasso:2.5.2'

In this library,

com.squareup.picasso - GROUP_ID
picasso -  ARTIFACT_ID
2.5.2 -  VERSION 

It is written as compile ‘GROUP_ID: ARTIFACT_ID: VERSION’

  • Now open local.properties(SDK Location)
  • and put
bintray.user=your bintary username
bintray.apikey=your api key(we can get this bintray profile settings)
bintray.gpg.password=1234(optional)

  • Now open android studio terminal
  • Run

./gradlew install 

android studio terminal command

Android studio terminal

 

  • After BUILD SUCCESSFUL
  • Again run 

./gradlew bintrayUpload

terminal command

Android studio terminal

  • After some time it will show BUILD SUCCESSFUL
  • And we are done.
  • Now open bintary repository.we will get all the details like version no.Click on version no.All the files will be available in file tabs.
jCenter library

Add to jCenter

  • At last click on Add to jcenter and in another tab just click send(no comment is required)
maven,add to jCenter

Add to jCenter

  • After 3-4 hours we will get one email like we can use our library after verification from bintray.
link jCenter android

Add to jCenter

  • Now we can use our library as compile ‘GROUP_ID: ARTIFACT_ID: VERSION

 

 

 

Author: Braj Bhushan Singh

Android Developer