Android JNI APK Packing

I have implemented a JNI Android application. This app requires several additional โ€œShared Libsโ€ to be packaged as part of the APK. Using Ecplise, I added these libraries to the project folder / libs / armeabi.

However, when the application starts (via the integrated debugger), my added "Shared Libs" are deleted from the "armeabi" folder.

  • How can I prevent the removal of these additional libraries?
  • How can I make sure that the additional required SOs are packaged in the APK?
+8
android android-ndk jni
source share
2 answers

You do not need to copy these libraries to the libs folder yourself. This job should be done using ndk-build .

These two steps should be enough:

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

  • For each library, add the following lines before the include $(CLEAR_VARS) , replacing mylib with your library name:

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

( LOCAL_SRC_FILES may require a slightly different path. It depends on the configuration of Eclipse.)

+9
source share

Another note to add in this context is that the path to the external SharedLib MUST be relative to the jni directory (or any spcified @LOCAL_PATH), that is, "LOCAL_SRC_FILES: = .. / .. / .. /Android/ffmpeg/libavcodec/libavcodec.so "will work where the absolute path will not.

+1
source share

All Articles