如何在Android Studio 2.2中添加预建* .so库

问题描述:

我试图将库添加到项目中,但是android studio忽略了我的lib. 我的CmakeLists.txt add_library( mylib SHARED IMPORTED ) set_target_properties(ffmpeg PROPERTIES IMPORTED_LOCATION src/main /libs/${ANDROID_ABI}/libmylib.so )

I tried to add library into project, but android studio ignore my lib. My CmakeLists.txt add_library( mylib SHARED IMPORTED ) set_target_properties(ffmpeg PROPERTIES IMPORTED_LOCATION src/main /libs/${ANDROID_ABI}/libmylib.so )

构建我的apk后不包含libmylib.so.如何使用cmake将预建的库添加到项目中?

After building my apk not contain libmylib.so. How to add prebuilt library into project with cmake?

当前需要由应用打包.可能是这样的:

currently need to pack it by the app. it could be something like:

    sourceSets {
        main {
            // let gradle pack the shared library into apk
            jniLibs.srcDirs = ['point/to/your/shared-lib']
       }
    }

一个示例是: https://github.com/googlesamples/android-ndk/blob/master/hello-libs/app/build.gradle 如果您的共享库[您位于项目路径内]与您的项目接近,则将共享库的相对路径放置到CMakeLists.txt中即可.

one example is: https://github.com/googlesamples/android-ndk/blob/master/hello-libs/app/build.gradle If your shared lib [yours is inside project path] is close to your project, put relative path of your shared-lib to your CMakeLists.txt would work.

此错误底部的一些背景讨论可能会有所帮助:

Some background discussion at the bottom of this bug might help: https://code.google.com/p/android/issues/detail?id=214664&can=8&q=vulkan&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened