如何使用集成的 openCv 库减小我的 Android 应用程序的 apk 大小 [英] How to reduce the apk size of my Android app with openCv library integrated

查看:56
本文介绍了如何使用集成的 openCv 库减小我的 Android 应用程序的 apk 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很多,但没有得到解决方案,因此发布了这个.

I have searched for this a lot, but didn't get a solution and hence posting this.

场景:我正在构建一个使用 opencv 库的 Android 应用程序.当我构建 APK 文件时,apk 的大小为66"MB,这对我的应用来说太大了.我使用的是最新版本的 OpenCV

Scenario: I'm building an Android app which uses opencv library. When I build the APK file the size of apk is '66' MB which is too much for my app.I'm using the latest version of OpenCV

分析:当我分析 apk 文件时,我可以看到由于 amr64、armeabi、mips、x86 等所有架构中的libopencv_java3.so"文件,文件大小太大.如果我删除所有这些文件并构建APK,然后大小仅为7 MB,只能与目标设备中安装的OpenCVManager一起使用

Analysis : When I analyze the apk file, I could see that the size is too big due to 'libopencv_java3.so' file in all architectures like amr64, armeabi, mips, x86 etc. If I remove all those files and build APK, then the size is 7 MB only, which can work only with OpenCVManager installed in the target device

问题:我不希望我的应用用户安装另一个应用 (OpenCVManager) 来运行我的应用.那么,只想知道,在没有 OpenCVManager 帮助的情况下,减少应用程序的 apk 大小的所有可能解决方案是什么?

Problem : I don't want my app users to install another app (OpenCVManager) to run my app. So, just want to know, what all are the possible solutions to reduce the apk size of the app to work without the help of OpenCVManager ?

推荐答案

您可以像这样在 build.gradle 文件中启用 ABI 拆分:

You can enable ABI splitting in the build.gradle file like this:

    android {
    // Some other configuration here...

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi', 'armeabi-v7a', 'mips'
            universalApk false
        }
    }
}

参考此链接 https://realm.io/news/reducing-apk-size-native-libraries/

这篇关于如何使用集成的 openCv 库减小我的 Android 应用程序的 apk 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆