Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Android Archive Library(AAR) with maven only

I am developing a library project which I would like to distribute to other developers.

There have been many discussions on this topic on internet, people suggested to create a distribute version library project which contains only my library project's jar & other resources. It sounds good.

Then, I suddenly found there are people suggested to create Android Archive Library (AAR). But they all uses a tool named Gradle

I am using Eclipse with Maven for my Android library project. My question is, is it possible to generate AAR achieve for my android library project without using Gradle but only with Maven? If so, how?

like image 889
Leem.fin Avatar asked Aug 01 '14 09:08

Leem.fin


People also ask

How do I publish AAR to Maven repository?

Uploading Android AAR to Local Maven RepositoryCreate an empty project without any activity. Create an AAR module. The URL file:\\DESKTOP-3PCHU10\site\ is a shared folder. Add “apply from: 'maven-publish.

How do I add AAR library?

Add your AAR or JAR as a dependency To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your .

How do I create a library for Android?

Creating The Android Library Open Android Studio and create a new Project. Name your application as ToasterExample and your project name as Toaster. The ToasterExample will be our sample application to show an example use of our application. Click on Finish and your project will be ready.


1 Answers

The android-maven-plugin allows to package a project as aar-file.

From their documentation http://simpligility.github.io/android-maven-plugin/:

Produce an AAR

If you have a bunch of Java code that you want to share then the best solution is to create a Java project and publish as a plain Java archive (ie jar).

But if you have code plus Android resources that you want to share then you really want to share that as an Android archive (ie AAR). Fortunately this is easy.

Just add configure your project to have packaging aar (and add the android-maven-plugin to build/plugins section of your maven project). Eg

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycoolcompany</groupId>
  <artifactId>general-lib</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <packaging>aar</packaging>

  ...
</project>
like image 62
Sven Avatar answered Sep 19 '22 13:09

Sven