How to create your custom selfhosted maven repository and publish your Android SDK

Publishing a Android SDK or library becomes so complicated without a right docs.

1. Install Sonatype Nexus Repository

This is the tool you will need. You can follow this blog to install Sonatype Nexus on your Ubuntu system. After installation, visit http://your_ip_address:8081 and you will get something just like this.

2. Sign In with your Admin credentials

When you will be access Nexus dashboard just Login with your credentials. Now your dashboard look like this.

3. Create repository

Now create a repository. Your library artifacts required this repository. Click on the setting icon button.

Now click on Repositories.

After that, A list of repositories will appear. just copy the url of any repository for now. In this blog, i will copy the url of “maven-releases”.

4. Modification in build.gradle

To publish your Android library, you will need to do some changes in your library’s build.gradle file.

For Gradle version below 8

if you are using a grale verison below 8, then you will need to use these gradle configurations to your build.gradle file.

Your complete build.gradle file

For Gradle version 8 or higher

If your gradle version is 8 or higher, than you just need to add a block inside android{}

Complete build.gradle file

5. Publish your Android library

Now its time to release your Android library. Just enter the following command in your terminal.

 ./gradlew publish

Congratulations, now your library has been published to your selfhosted nexus.