Android Creating your own libraries for Android applications Create a library available on


Perform the following steps to create the library:

  1. Create a GitHub account.

  2. Create a Git repository containing your library project.

  3. Modify your library project's build.gradle file by adding the following code:

    apply plugin: ''
    // Build a jar with source files.
    task sourcesJar(type: Jar) {
        classifier = 'sources'
    task javadoc(type: Javadoc) {
        failOnError  false
        source =
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
        classpath += configurations.compile
    // Build a jar with javadoc.
    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier = 'javadoc'
        from javadoc.destinationDir
    artifacts {
        archives sourcesJar
        archives javadocJar

    Make sure that you commit/push the above changes to GitHub.

  4. Create a release from the current code on Github.

  5. Run gradlew install on your code.

  6. Your library is now available by the following dependency:

    compile 'com.github.[YourUser]:[github repository name]:[release tag]'