How to create apklib for non maven project

My Android application depends on the android library project, which comes from a third party. I switch my build environment to maven even after the samples go pretty smoothly, but the last step is this. I don’t understand what I really need to do . I read the apklib page here . I have never seen a document dance around what you are actually doing better than this document. It contains 1 fragment of how you link to apklib, but no information on how you generate it?

In addition, my project structure is as follows:

/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 this separation of modules:

 <modules> <module>shared/lib1</module> <module>shared/lib2</module> <module>app</module> </modules> 

Is it correct? In all examples of modules, I see that they refer to direct child folders, while mine are nested further.

The main thing I'm looking for is to make lib2 apklib a link to app / pom.xml.

+6
source share
1 answer

In the link you referred to ::

Non-Maven Android Library Project Compatibility!

The generated .apklib file will have the layout of the standard Android / Eclipse library project. This means that regardless of your Maven layout, the layout inside the .apklib file will be that the source code is in "src /" instead of "src / main / java /", but is still interpreted correctly when used in an Android / application Maven project. This should be compatible with library projects of developers other than Maven, which is important for the development of the Android developer community.

Use other non-Maven developer libraries

This also means that we can use any external project of the Android library project zip file (from developers other than Maven), and make mvn install: install-file ... on it and just start using it as a dependency.

Share your .apklib with developers without Maven

To share their .apklib file with a developer other than Maven, they are likely to feel more comfortable if you rename it to .zip. Then they can simply unzip it into a directory and use it from there.

If this is an anonymous Android library project, just run mvn clean install to create apklib and install it in the local Maven repository.

If this is a regular Android library project, just write down the project folder (it is better to delete all unnecessary files with IDE files), rename my-lib.zip to my-lib.apklib, then run mvn install:install-file to install my-lib. apklib to the local Maven repository.

Please note that in your maven multi-module project, if the lib2 child module is not clouded, you may get some configuration error when you run the maven build, this is called a multi-module Maven project, so it makes no sense to include a weak child project. If lib2 is not overwhelmed yet, either cancel it as part of the maven mlili module project, or remove it from the maven mlili module project and save it separately (both from the command line and using the apklib and IDE development through the source).

Also note that creating a project in Maven and Eclipse is a completely different story, if you create / import a project in the IDE, you still need the source of the library project. If lib2 is anonymous as part of a multi-module project, it will be imported and configured automatically when you import the parent project, otherwise you may need to import and configure a separate project manually. See this answer and this answer for details.

+2
source

All Articles