Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build apk is too large about 100m.how to resize it #40

Open
H-TWINKLE opened this issue Jan 25, 2025 · 2 comments
Open

build apk is too large about 100m.how to resize it #40

H-TWINKLE opened this issue Jan 25, 2025 · 2 comments

Comments

@H-TWINKLE
Copy link

No description provided.

@sz3
Copy link
Owner

sz3 commented Jan 25, 2025

I assume you're building it locally?

The opencv libraries (in a directory like OpenCV-android-sdk/sdk/native/libs/arm64-v8a/) are the biggest files in the final apk -- and the only platform we're really supporting is arm64, so the others are wasted space. The other libopencv_java4.so files don't need to be in the apk, which should help a bit.

Beyond that, I'm not sure. 100MB seems excessive, it'd be interesting to see a list of what the largest files are inside it.

(extra trivia: for a while I was trying to statically link opencv to get the apk down into the 5MB range, but never got it working and got distracted by something else...)

@H-TWINKLE
Copy link
Author

thanks. i solve the problem through the following methods.

Android Studio Ladybug Feature Drop | 2024.2.2
OpenCV-android-sdk.4.8.1

splits {
        // Configures multiple APKs based on ABI.
        abi {

            // Enables building multiple APKs per ABI.
            enable true

            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for x86 and x86_64.
            // Resets the list of ABIs that Gradle should create APKs for to none.
            reset()

            // Specifies a list of ABIs that Gradle should create APKs for.
            // include "x86", "x86_64", "arm64-v8a", "armeabi", "armeabi-v7a"
            include "arm64-v8a"

            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants