fix(scanner): stop packaging the unused OpenCV Java library - #1604
Merged
Merged
Conversation
libcodeScanner.so links OpenCV statically, so nothing loads libopencv_java4.so. The :vendor:opencv:sdk dependency only put that library, about 130 MB across four ABIs, into the APK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The release APK is 267 MB, and 130 MB of that is
libopencv_java4.sofor four ABIs (22 MB on arm64). Nothing loads it.The scanner's CMake links OpenCV statically. The Android SDK's
OpenCVConfig.cmakesetsOpenCV_SHARED OFF, andfind_packagereads it straight fromvendor/opencv/sdk/native, so the native build never needed the Gradle dependency. The only thingimplementation(project(":vendor:opencv:sdk"))did was put the SDK's prebuiltlibopencv_java4.sointo the APK.In the arm64 release build:
libcodeScanner.sodefines 1,642cv::symbols and leaves none undefined. It has noNEEDEDentry forlibopencv_java4.so, andlibkikCodes.soneeds onlylibcodeScanner.so.opencv_java.libcodeScanner.sodoes importdlopen, but every library name in it belongs to OpenCV's optional TBB, VTune and parallel-plugin hooks. None of those ships in the APK today.org/opencvreferences, and outsidevendor/opencv/no code usesorg.opencvorOpenCVLoader.libc++_shared.so, about 1 MB per ABI, leaves with it:libopencv_java4.sowas the only library that needed it.Play installs are smaller by the arm64 slice. The universal APK that
build_flipcashbuilds with bundletool loses the full 130 MB.:vendor:opencv:sdkis still insettings.gradle.ktsand the OpenCV Gradle plugin is still on the root classpath. Both can go in a follow-up, but thenative/files have to stay because CMake reads them.