How to create a library on Github and use it through gradle dependencies in Android Studio

I want to create the library and have access to it through the Internet.
In Android Studio (via Gradle) dependency may be added in this way:

In build.gradle (Module app):

  • What is Repo and Why does Google use it?
  • How does the Android repo manifest repository work?
  • How to git clone an OpenShift application to Android
  • Connect my project to gitlab with android studio
  • How to Organize Android App with Multiple Versions of Assets
  • Android Studio showing unchanged files in commit changes dialog box
  • dependencies {
        compile ''
        compile 'com.squareup:otto:1.3.8'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.j256.ormlite:ormlite-core:4.48'
        compile 'com.j256.ormlite:ormlite-android:4.48'

    How can I add my own library in this way from github?

  • github url style
  • cap deploy:cold fails with 'No such file or directory - git rev-parse master' error
  • Cloning git repository Failure
  • How to manage a project on GitHub that has an external git dependency not stored on GitHub
  • Multiple github accounts: what values for Host in .ssh/config?
  • Forking using TFS Git
  • 3 Solutions collect form web for “How to create a library on Github and use it through gradle dependencies in Android Studio”

    Refer Jitpack is best to import your project or libs from Github to gradle

    For more information refer Gabriele Mariotti answer

    To achieve it you have some ways:

    1. publish your library (artifact) in central maven or jcenter.
    2. use a github repo and the jitpack plugin
    3. use a private maven

    The point 2. is very simple.

    Just push your codein github and modify the gradle script in the project where you want to use it.

    Just add this repo tp your build.gradle

    repositories {
            // ...
            maven { url "" }

    and the dependency:

    dependencies {
            compile 'com.github.User:Repo:Tag'

    To publish a library in Central Maven or JCenter, it is very long to explain in an answer. Hovewer you can read these posts:

    • Publish on JCenter

    • Publish on Central Maven. Another blog for Central Maven

    For a quick solution, as the others have said JitPack is probably the way to go. However, if you want to make your library available to a wider audience you should probably add it to jcenter since this is set up by default in Android Studio now. (Previously it was Maven Central.)

    This post gives a detailed walkthrough of how to do it. The following is a summary:

    1. Create the Android library
    2. Test to make sure the library is usable locally
    3. Publish the library on Bintray
    4. Add the library to Jcenter

    Then all people will have to do to use your library is add a one liner to their build.gradle dependencies.

    Git Baby is a git and github fan, let's start git clone.