简体   繁体   English

在新项目Android中使用预构建的共享库(.so)

[英]Using prebuilt shared library (.so) in new project Android

如何在不重新编译本机代码和所有内容的情况下执行此操作?

It seems like you are probably doing jni to this library. 看来您可能正在对此库执行jni。 If that is the case, the java package and class name needs to be encoded in the names of the jni functions, so you would have to do something such as: 如果是这种情况,则需要在jni函数的名称中编码java包和类的名称,因此您必须执行以下操作:

  • Always keep the same name for the java package and class file which actually interfaces to the native library. 实际与本机库接口的java包和类文件的名称始终相同。 This does not need to match the main package name for the APK. 不需要与APK的主包名称匹配。 You may want to make this a sort of wrapper for the native library. 您可能要使它成为本机库的一种包装。

  • Or you could create a new native library using the new package name which is just a wrapper calling the original library by it's original function names. 或者,您可以使用新的程序包名称创建一个新的本机库,该程序包名称只是一个包装器,该包装器通过其原始函数名来调用原始库。 This will be a bit more complicated to set up than the previous idea. 设置起来比以前的想法要复杂一些。

Create libs/<arch> folder, and put the so file there. 创建libs/<arch>文件夹,然后将so文件放在此处。 Eclipse or ant build system will automatically pick it up and package in apk file. Eclipse或ant构建系统将自动将其拾取并打包为apk文件。

In place of <arch> use one of armeabi , armeabi-v7a , x86 or mips - depending on how .so file has been built. 代替<arch>使用armeabiarmeabi-v7ax86mips -取决于.so文件的构建方式。

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

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