To have your library listed on Gradle, Please (and have people include your library easily), upload your project to Maven Central. The easiest way to do this is via Sonatype.

Sonatype

Create a JIRA account on Sonatype Once you are logged in, create a new issue.

I have created a GitHub repo for my project Trestle . So I filled out the fields in the new issue like so :

Group Id : com.github.<github_username>

Project URL : https://github.com/<github_username>/<project_name>

SCM url : https://github.com/<github_username>/<project_name>.git

Username : <sonatype_username>

Already Synced to Central : No

Note: I have added brackets around fields as placeholders. You will need to substitute with the appropriate values.

When you submit the issue, the details of the issue should look similar to the screenshot above. After you submit, it can take up to 2 business days to process your issue. Then you will receive a confirmation that your configuration has been prepared and you can publish your library.

Do not deploy until after you have received an e-mail notice indicating that the ticket is Resolved. One of the most common problems related to new projects is premature deployment, which misroutes your artifacts to a catch-all repository.

Lastly, if your component is already in Central be sure to note this in your ticket, and review how to migrate to OSSRH.

The SonaType OOSRH Guide has more details about this process.

Modify a file on your local machine ~/.gradle/gradle.properties and include

NEXUS_USERNAME=sonatype_username

NEXUS_PASSWORD=sonatype_password signing.keyId=gpg_key_id

signing.password=gpg_password

signing.secretKeyRingFile=/Users/username/.gnupg/secring.gpg org.gradle.daemon=true

Authentication is provided by this gradle.properties when publishing the library. Make sure you have provided the correct nexus username and password (this is the Sonatype user name and password) otherwise you get an unauthorized 401 error .

Note : If you have already published a library then you won’t need to create a new issue on JIRA(Sonatype). Only one JIRA issue per top-level groupId is necessary. You should already have all the necessary permissions to deploy any new artifacts to your groupId or to any sub-groups. The sync to Central applies from your top level groupid on down, so any releases to sub groups will automatically sync. There’s no need to tell Sonatype when you release a new component, since there’s nothing left for Sonatype to configure or check once your repo syncs, and they only post to twitter when the sync is first activated.

Publish

Once you are ready to publish your library, in Android Studio open the Gradle View on the right side. Under Tasks > upload click on uploadArchives. This will upload your library to the Sonatype Staging Repositories .

Make sure you are logged in with your Sonatype account when going to the Sonatype Staging Repositories webpage. Look for your “staging” library. It should be at the end of the list. Select it, and press “Close” button. Closing a library actually means that you’re ready to release it. If closing went fine — you should see a ‘Release’ button active. You may need to refresh the page. Press the release button. Checkout the helpful documentation on Repository Management with Nexus. If this is the first library that you are publishing then get back to JIRA and post a comment there that you promoted you library. Otherwise it is unnecessary to let Sonatype that you promoted your library. After that you should get a response from Sonatype that your library will be available in about ten minutes and it will be synced with the Maven Central in the next few hours. It may take a few hours before it shows up on Gradle, Please .

Library Usage

For other developers to use your library they will need to add a dependency to the build.gradle file of their Android project.

apply plugin: 'android' dependencies {

compile 'com.github.lawloretienne:trestle:0.0.3'

}

Shoutout

Special thanks to Chris Banes, Jonathan Le, Serge Zaitsev and others for their blog posts which helped me get through this tricky process.

Chris Banes — Pushing AARs to Maven Central

Jonathan Le — Publishing an Android Library (AAR) to a Maven Repository

Serge Zaitsev — SIMPLE LIBRARY PUBLISHING WITH GRADLE

My Libraries