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

查看:340
本文介绍了如何使用集成的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天全站免登陆