cfc icon indicating copy to clipboard operation
cfc copied to clipboard

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

Open H-TWINKLE opened this issue 11 months ago • 2 comments

H-TWINKLE avatar Jan 25 '25 03:01 H-TWINKLE

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...)

sz3 avatar Jan 25 '25 06:01 sz3

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

H-TWINKLE avatar Feb 07 '25 07:02 H-TWINKLE