You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we use an IMPORTED SHARED library in CMake build, it is not packed into the APK. This behaviour is not consistent with what happens when we use ndk-build instead of CMake.
sourceSets {
main {
// let gradle pack the shared library into apk
jniLibs.srcDirs = ['../distribution/gperf/lib']
}
}
The latter solution is less attractive to me because it involves sharing some knowledge (e.g. paths to native dependencies) between CMake and Gradle. It's preferable IMO to handle this entirely in CMake and copy the file to CMAKE_LIBRARY_OUTPUT_DIRECTORY:
At the very least, this issue should be properly documented.
It would help a lot to add some helper macro to the CMake toolchain file, which would take care of declaring an imported shared library and packing it into the APK, so that CMake is on par with ndk-build.
I believe it's possible to teach the Gradle plugin pack such libraries without changing the user-side scripts, but maybe today this would cause more confusion, because this would be a braking change for the behaviour that has been there for quite a while.
The text was updated successfully, but these errors were encountered:
I'm pretty sure I fixed this as part of #916. AGP 4.0 shouldn't have this problem. It's definitely fixed for the case of a library imported via a config package. I'll wait to make sure your project agrees before fixing the docs :)
You shouldn't need to do any sort of cofig with 4.0. Just depending on the library should get it added to the APK.
This Feature Request should be part of the NDK integration for CMake, and is based on a common scenario, see How can I integrate OpenCV 4.0 into a pure C++ Android NDK project?.
When we use an IMPORTED SHARED library in CMake build, it is not packed into the APK. This behaviour is not consistent with what happens when we use ndk-build instead of CMake.
An official sample suggest a way to do this in Gradle:
The latter solution is less attractive to me because it involves sharing some knowledge (e.g. paths to native dependencies) between CMake and Gradle. It's preferable IMO to handle this entirely in CMake and copy the file to
CMAKE_LIBRARY_OUTPUT_DIRECTORY
:At the very least, this issue should be properly documented.
It would help a lot to add some helper macro to the CMake toolchain file, which would take care of declaring an imported shared library and packing it into the APK, so that CMake is on par with ndk-build.
I believe it's possible to teach the Gradle plugin pack such libraries without changing the user-side scripts, but maybe today this would cause more confusion, because this would be a braking change for the behaviour that has been there for quite a while.
The text was updated successfully, but these errors were encountered: