Publish the AAR Locally in Android

Amit Gupta
2 min readFeb 7, 2024

--

This topic covers how we can use the local Machine to publish AAR for a SDK without publishing it on Repositories. It will help the developers to test the SDK into the Client App before publishing to central repositories.

First write the task in build.gradle of the SDK folder which will publish the AAR locally for the SDK:

Apply the Maven Plugin mentioned above.

Define the Artifact in afterEvaluate{} block as:

Create the task inside after it like that:

command ./gradlew buildAndPublishReleaseToMavenLocal

By executing the above command, developers can now generate a local AAR file and verify its successful creation in the Users/username/.m2/repository folder.

Now Modify the Main app’s build.gradle to include mavenLocal() in the repositories block.

Now in Main app’s build.gradle use this local published aar like the central repository sdk:
implementation ‘com.example:my-library:1.0.0’

That’s all and you can test your SDK into your main app multiple time locally now.

--

--

Amit Gupta
Amit Gupta

No responses yet