简体   繁体   English

对于Android项目,我如何使Maven拾取lib目录中的所有库,包括.so文件?

[英]For Android project how do I get maven to pickup all libraries in lib directory including .so files?

I have project that compiles and links fine when using Eclipse IDE. 我的项目可以在使用Eclipse IDE时进行编译和链接。 This project uses some external jar files and also uses some of JNI ( .so ) libraries. 该项目使用一些外部jar文件,还使用一些JNI(.so)库。

They are all located in the libs/ directory of my project. 它们都位于我项目的libs /目录中。 How should my pom.xml file look like in order for all the jar files in libs/ folder and the shared objects are included in the APK. 为了使libs /文件夹中的所有jar文件以及共享对象都包含在APK中,我的pom.xml文件应如何显示。 My libs directory looks something like this: 我的libs目录看起来像这样:

libs/
├── mydevicelib.jar
├── armeabi
│   ├── libdevice.so
├── armeabi-v7a
│   ├── libdevice.so
│   ├── libcmiris.so
├── libcommon.jar

I am using maven 3.0.5 我正在使用Maven 3.0.5

These jars should be included as dependencies in the maven POM. 这些jar应该作为依赖包含在Maven POM中。

Rather than include them in a local lib folder they should be deployed to a maven repository. 与其将它们包括在本地lib文件夹中,不如将它们部署到Maven存储库中。

For any artifacts that are available through maven central repository just include the dependency directly from there. 对于可通过Maven中央存储库获得的任何工件,只需直接从那里包括依赖项即可。

For custom artifacts, the best way to do this is to set up your own maven repository ( http://archiva.apache.org/index.cgi or http://www.sonatype.org/nexus/ ) and deploy the artifacts to that. 对于自定义工件,最好的方法是设置自己的Maven存储库( http://archiva.apache.org/index.cgihttp://www.sonatype.org/nexus/ )并部署工件对此。 Then you can include them as dependencies in the pom. 然后,您可以将它们作为依赖项包含在pom中。

Alternatively, if this is overkill for your project, you can set up a local project repository and deploy the artifacts to that. 或者,如果这对于您的项目而言过于矫kill过正,则可以设置本地项目存储库并将工件部署到该项目存储库。

I havent actually done this with JNI libraries, though this link looks like it may contain useful info for doing a similar thing there: http://code.google.com/p/maven-android-plugin/wiki/NativeLibsAsDependencies . 我实际上并未使用JNI库完成此操作,尽管此链接看起来可能包含在此处进行类似操作的有用信息: http : //code.google.com/p/maven-android-plugin/wiki/NativeLibsAsDependencies Looks like you just need to add the 看起来您只需要添加

<type>so</type>

element to the dependency. 依赖项的元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM