简体   繁体   English

如何将ndk-build用于应用程序库

[英]how to use the ndk-build for application library

I had to build a library using ndk-build. 我不得不使用ndk-build构建一个库。 Did that. 做过某事。 it produced all the libXX.so files. 它产生了所有的libXX.so文件。 It already had a apk file in the bin dir. 它在bin目录中已经有一个apk文件。 Now how does this fit together. 现在,如何将它们组合在一起。 Should I be installing all the lib in the lib folder of my android phone and then install the apk and run it . 我应该将所有的lib安装在我的android手机的lib文件夹中,然后安装apk并运行它。 Is this the way? 是这样吗

Do you use a build system? 您是否使用构建系统? Using Maven I used a local repository and put the .so files there (in appropriately named) directories, and then my build process picked them up when creating the apk. 使用Maven,我使用了本地存储库,并将.so文件放在适当的命名目录中,然后在创建apk时,我的构建过程将它们选中。 Let me know how you are building your apk and I might be able to help further. 让我知道您如何构建自己的APK,也许我可以提供进一步的帮助。

Edited to include some Maven stuff 编辑以包括一些Maven内容

Dependency on a native library: 对本机库的依赖:

<dependency>
    <groupId>android.native</groupId>
    <artifactId>libhello-jni</artifactId>
    <version>0.8</version>
    <classifier>armeabi-v7a</classifier>
    <type>so</type>
</dependency>

Using a local repository (where ${third-party-jars} is a path on your system eg <third-party-jars>/local/path/to/third/party/jars</third-party-jars> : 使用本地存储库(其中${third-party-jars}是系统上的路径,例如<third-party-jars>/local/path/to/third/party/jars</third-party-jars>

<repository>
    <id>third.party.closed.source.local.repo</id>
    <name>Third Party Closed Source Local Repository</name>
    <url>file://${third-party-jars}</url>
    <!-- Files must be in groupId/artifactId/version directories and named
         artifactId-version.extension
         Example: ${groupId/$artifactId/$version/$artifactId-$version.$extension -->
</repository>

The Maven build then just picks the so up as a dependency like it would a jar file etc. 然后,Maven构建会像选择jar文件一样将其作为依赖项。

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

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