Android的JNI APK包装Android、JNI、APK

2023-09-07 16:33:48 作者:世间万物

我实现了一个JNI的Andr​​oid应用程序。此应用程序需要一些额外的共享库被包装为APK的一部分。使用Ecplise,我已经添加了这些库到项目的'/库/ armeabi文件夹中。

I have implemented a JNI android application. This application requires a few additional 'Shared Libs' to be packed as part of the APK. Using Ecplise, I have added these libs to the project's '/libs/armeabi' folder.

然而,启动应用程序(通过集成的调试器)的时候,我增加了共享库'是从'armeabi文件夹中删除。

However, when launching the application (through the integrated debugger), my added 'Shared Libs' are removed from the 'armeabi' folder.

如何prevent从这些额外的库被删除?如何确保其他所需的战略目标是装在APK?

推荐答案

您不必复制此库文件夹自己。这项工作应该由要做的 NDK的构建

You don't need to copy this libraries to libs folder yourself. This job should be done by the ndk-build.

这两个步骤应该是足够了:

These two steps should be enough:

创建 mylibs (你可以使用任何其他名称代替)上的文件夹项目的根目录下。并把你的库到这个文件夹。

Create mylibs (you can use any other name instead) folder on the root level of your project. And put your libraries into this folder.

对于每个库前添加以下行包括$(CLEAR_VARS)语句替换 MYLIB 与您库名称:

For each library add the following lines before the include $(CLEAR_VARS) statement replacing mylib with you library name:

include $(CLEAR_VARS)
LOCAL_MODULE:=mylib
LOCAL_SRC_FILES:=../mylibs/libmylib.so
include $(PREBUILT_SHARED_LIBRARY)

(您可能需要为 LOCAL_SRC_FILES 略有不同的道路。这取决于你的Eclipse配置。)

(You might need slightly different path for LOCAL_SRC_FILES. It depends on your Eclipse configuration.)