How do you link third party library in Android cmake external build system?

后端 未结 2 447
野趣味
野趣味 2020-12-15 23:35

Android Studio 2.2 introduces cmake external build system. The problem is that documentation is really lacking and I do not know how should I link third party libraries? I\'

相关标签:
2条回答
  • 2020-12-16 00:35

    For now I ended up copying libSomething.so to cmake library output directory in a post build step. This works because it turns out that Android Studio copies into apk EVERYTHING that is in that directory.

    Command in cmake is the following:

    add_custom_command(TARGET native-lib POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy
            ${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libSomething.so
            ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libSomething.so
        )
    
    0 讨论(0)
  • 2020-12-16 00:36

    For now, you could also put your shared libs into directory, and configure jniLibs to point to that directory, that will pack it. One sample is here: https://github.com/googlesamples/android-ndk/tree/master/hello-libs, follow gperf see if that helps. This way app not depending on the generated build folders. When android studio added packing libs, the jniLibs workaround is not necessary anymore

    0 讨论(0)
提交回复
热议问题