Ask Your Question

How to reduce the apk size of Android app which need openCv lib( only for Image processing)

asked 2017-07-07 00:03:31 -0500

shakeeb gravatar image

updated 2017-07-07 00:14:15 -0500

berak gravatar image

I have tried through several answers like apk split , Flavors Build but it does not works for me.

I'm building an Android app with min sdk 15, which uses opencv library.The problem is when I build apk size of it is more then 60 MB which is not very great.

I checked the app file, I could see that the size is too big due to file in all architectures like amr64, armeabi, mips, x86 etc.

image description

I am using openCv only for image processing.This library has a lot of other features like video processing, 3d image, object detection and much more, which I don't need in my app like

If I remove all those files and build APK, then size will be reduced 50 mb , but to make this app work I need to install OpenCVManager to run my app.

Is there any way by which I can reduce my apk size?

Or is it possible just to extract only the feature from openCv which I am intersted in and create .so for those features?

edit retag flag offensive close merge delete


i'm no more using android, but you'd have to build your own sdk with a reduced, and use static initialization (init_Debug() or what it was called), and NOT using the opencv manager, right ?

meaning: you'd have to interfere with cmake and choose a limited set of modules (not all there is), when building

berak gravatar imageberak ( 2017-07-07 00:08:24 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-07-12 04:07:40 -0500

rhardih gravatar image

You should consider splitting your APK into architecture specific versions:

That way you only need to include one version of OpenCV pr. APK, e.g. arm64-v8a.

That should give you the size reduction you're looking for.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-07-07 00:02:39 -0500

Seen: 3,245 times

Last updated: Jul 12 '17