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?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With