NDK - How to use a generated .so library in another project

前端 未结 3 1577
感动是毒
感动是毒 2020-11-29 18:24

I have used ndk successfully to build & use a .so file in one project. I need to use this library in another project. I would rather not copy the source the

3条回答
  •  再見小時候
    2020-11-29 19:03

    I figured out a way to do this, so posting it here in case someone else runs into it.

    1. The code to be shared (including the Java JNI wrapper, native code, .so library), should be in a separate project. Convert this to a Library project by right-click on project name --> properties --> Android properties --> check mark "Is Library". This project cannot be executed now but can be referenced by other projects.

    2. In the project which will use the shared object, add a reference to the Libarray project by right-click on project name --> properties --> Android properties --> Library/"Add". This should show up the Library project created in the previous step. Select it.

    Now the .so can be referred to easily between different projects.

提交回复
热议问题