Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add prebuilt *.so library in android studio 2.2

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 )

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

like image 285
streit Avatar asked Oct 20 '16 18:10

streit


People also ask

How do I use prebuilt .so lib files?

Declare a prebuilt library Give the module a name. This name does not need to be the same as that of the prebuilt library, itself. In the module's Android.mk file, assign to LOCAL_SRC_FILES the path to the prebuilt library you are providing. Specify the path relative to the value of your LOCAL_PATH variable.

What is .so file in Android?

The SO file stands for Shared Library. You compile all C++ code into the.SO file when you write it in C or C++. The SO file is a shared object library that may be dynamically loaded during Android runtime. Library files are larger, often ranging from 2MB to 10MB in size.

What is Lib folder in APK?

lib — directory with compiled native libraries used by your app. Contains multiple directories — one for each supported CPU architecture (ABI). META-INF — directory with APK metadata, such as its signature. AndroidManifest.


1 Answers

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']
       }
    }

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

like image 68
Gerry Avatar answered Oct 04 '22 18:10

Gerry