How to reduce the web-RTC library size?
Asked Answered
Q

2

6

I was following the instruction given by quick blox as below: https://quickblox.com/developers/Sample-webrtc-android

dependencies 
{
compile 'com.quickblox:quickblox-android-sdk-videochat-webrtc:3.3.0'
}

Initially my apk size is 9MB but when I integrated quickblox video chat in my application, apk size increased to 45 MB due to below platforms of different .so files:

>arm64-v8a
>armeabi-v7a
>x86
>x86_64  

libraries - libjingle_peerconnection_so.so

Is there any way or suggestions to reduce apk size?

Quito answered 11/3, 2017 at 4:33 Comment(2)
any solution for this? I need also same solutionStedfast
Which modules of webrtc you are using? Is there any particular single module or multiple module ? Modules od WEBRTC are core module, users module, messages module, content module, chat module and videochat-webrtc module .Rollo
C
5

I was looking into the sample code provided by QuickBlox and found that you can save upto 10 MB of apk but you have to build 4 apks. You can check the gradle file

 /*There is code for excluding some native libs (it useful if you need reduce apk size and want
build apk only for specific platform). This method allows you to achieve savings about 10MB
of apk's size (but you need build 4 different apks). */
    packagingOptions {
        exclude '**/armeabi-v7a/libjingle_peerconnection_so.so'
        exclude '**/arm64-v8a/libjingle_peerconnection_so.so'
        exclude '**/x86_64/libjingle_peerconnection_so.so'
        exclude '**/x86/libjingle_peerconnection_so.so'
    }

About Multiple APKs

Different Android handsets use different CPUs which in turn support different instruction sets. Each combination of CPU and instruction sets has its own Application Binary Interface, or ABI

  • armeabi-v7a

    arm64-v8a

    x86_64

    x86

These are ABI

building 4 apks meant you can create apk for these 4 ABI's separately. The main idea is to not include the libraries which are not meant for specific ABI thus reducing the size by including only the libraries which are required for that ABI

e.g.

splits {
        abi {
            enable true
            reset()
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for
            universalApk true //generate an additional APK that contains all the ABIs
        }
    }

Update:

How to upload multiple APKs to PlayStore?

this question has already been asked on SO. please check this question

Cootch answered 20/2, 2018 at 7:1 Comment(8)
This looks right solution. Can you give explanation about build "4 different apks" I will give bounty immediately. Thanks for your answer :)Stedfast
@RanjithKumar i have added explanation about building 4 different apk. please checkCootch
Thanks for updated answer. I will check & offer bounty tonight. Please give me time for check thisStedfast
I am not tested. But I hope it works. Please give me how to upload these 4 different APKs in play store?Stedfast
We can do with split option but it's again huge process to maintain or upload 4 apk's every-time when we push update to playstore. Is there any other way where we can use some other lib or some optimization?Quito
@VenSan according to their sample code this seems the only way. I have integrated Sinch Video Call in one of my app and its size was increased around 20 MB. If you can switch try SinchCootch
@Sahil can we do the same split process for Sinch to reduce more size?Quito
@VenSan i haven't tried but they seem to support this for ios. have a lookCootch
C
-2

It mandatory to add those files if you want to add video call or audio call capabilities to your application. With shrinking your apk size there are a lot of articles about it but there is not too much regarding the jnilibs with quickblox.

Google Developer Docs on shrinking size

Hope it helps.

Clock answered 11/3, 2017 at 20:37 Comment(1)
Your answer for common app size reduction. This question asked about particular library size.Stedfast

© 2022 - 2024 — McMap. All rights reserved.