如何在Android Studio 2.2中添加预建* .so库 [英] How to add prebuilt *.so library in android studio 2.2

查看:52
本文介绍了如何在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

这篇关于如何在Android Studio 2.2中添加预建* .so库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆