Last Updated: February 25, 2016
·
2.259K
· foobraco

Using Android Library Projects with Maven

Your Android project has to have the android maven plugin in its pom.xml file in order to unpack the android library project that you are going to package as an apklib.

The first thing you have to make is go to the root directory of your Android Library Project, compress it all in a zip file, and rename to the extension apklib

The files included in this gist are the maven script to convert your new apklib file into a dependency in your maven repo and the second one is the structure to add the dependency on the android pom.xml file.

This is the script to generate the apklib in your local maven repository

mvn install:install-file \
  -DgroupId=org.abc \
  -DartifactId=mywidget \
  -Dpackaging=apklib \
  -Dversion=1.0.0 \
  -Dfile=mylib.apklib \
  -DgeneratePom=true

and this is how you add the dependency in your pom.xml

 <dependency>
    <groupId>com.heyzap</groupId>
    <artifactId>sdk</artifactId>
    <version>3.4.5</version>    
    <type>apklib</type>
</dependency>