Android JNI APK Packing

本小妞迷上赌 提交于 2020-01-14 07:46:37

问题


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.

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

  • How can I prevent these additional libs from being removed?
  • How can I make sure the additional required SOs are packed in the APK?

回答1:


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:

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

  2. 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)
    

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




回答2:


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



来源:https://stackoverflow.com/questions/9101220/android-jni-apk-packing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!