My android application depends on an android library project which comes from a 3rd party. I am switching my build environment over to maven and following the samples has gone fairly smooth but the last step is this. I don’t understand what I actually need to do. I’ve read the apklib page here. I’ve never seen a document dance around what you actually do better than this document. It contains 1 snippet of how you reference an apklib but no information at all about how you actually generate it?
Also, my project structure looks like this
/projectroot/app (main application android project source code)
/projectroot/shared/lib1
/projectroot/shared/lib2 (3rd party lib i don't want to create pom.xml for)
I have projectroot/pom.xml with a modules section like so:
<modules>
<module>shared/lib1</module>
<module>shared/lib2</module>
<module>app</module>
</modules>
Is this the correct? In all the module examples I see they refer to folders direct children whereas mine are nested further.
Main thing I’m looking for is how to make lib2 an apklib to reference from app/pom.xml.
It is mentioned in the link you referenced:
If it is a mavenized Android library project, simply run
mvn clean installto create the apklib and get it installed in your local Maven repository.If it is a regular Android library project, simply zip the project folder (better to strip all unnecessary IDE generated files), rename my-lib.zip to my-lib.apklib, then run
mvn install:install-fileto install my-lib.apklib into your local Maven repository.Note that in your multi-module maven project, if the child module lib2 is not mavenized, you may get some configuration error when running maven build, it is called multi-module Maven project after all so does not make much sense to include a non-mavenized child project. If the lib2 is not mavenized yet, either mavenize it as part of the mutli-module maven project or remove it from mutli-module maven project and maintain it separately (from both command-line build via apklib and IDE development via the source).
Also note that project building in Maven and Eclipse are totally different story, if you are creating/importing the project into IDE, you need the library project source anyway. If lib2 is mavenized as part of the multi-module project, it will be imported and setup automatically when import the parent project, otherwise, you may need import and setup the standalone project manually. Check out this answer and this answer for more details.