NeutrinosPlatform / cordova-plugin-document-scanner

cordova plugin for document scan
https://www.neutrinos.co/
MIT License
84 stars 63 forks source link

Apk size increases after plugin installation #45

Closed yashashri10 closed 5 years ago

yashashri10 commented 5 years ago

I have installed plugin in ionic project. Functionality working fine but apk size increases. Previously before adding plugin apk size is just 15 MB but after installing this plugin apk size increases upto 60MB.

Please need help.

ChrisTomAlx commented 5 years ago

Hey @yashashri10

The plugin holds 32 bit and 64 bit architectures for 3 types of CPUs. You can shrink the apk by building your app only for arm and x86. This article mentions why some architectures are unnecessary. It also has steps on how to further reduce apk size (But I don't recommend those).

Refer issue #8 if you get stuck while following the below steps.

  1. Open your project in android studio or find the apps build.gradle file without using android studio (Google is your friend :) )
  2. Insert the following code into your android apps build.gradle [Module : App]
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
  1. It will look like this in your apps build.gradle.

    defaultConfig {
        versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
        applicationId privateHelpers.extractStringFromManifest("package")
    
        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
    
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
    }
  2. arm64-v8a & x86_64 architectures are 64 bit architectures and you probably need to include this if you want to be a hit on the playstore. If it is a single device apk you can further strip the architectures down to the only one required by your device. We have removed the mips 32 bit and 64 bit architectures by doing this.

Let me know if you need more help.

Cheers and have a nice day :) Chris Neutrinos

yashashri10 commented 5 years ago

@ChrisTomAlex Thank you for reply. I will integrate it and get back to you. :)

ChrisTomAlx commented 5 years ago

Closing this issue since I think this should help. Please let me know if you run into trouble and need to reopen the issue.

Cheers, Chris Neutrinos

akhilvenkateswaran commented 4 years ago

Hi,

The android apk generated in the demo link https://github.com/jhansireddy/AndroidScannerDemo/tree/master/ScanDemoExample/apk is just 5.4 MB. Can you explain the reason for the drastic increase(around 40 MB) in apk size after addition of the plugin, which uses the same scan library?

ChrisTomAlx commented 4 years ago

Hey @akhilvenkateswaran If you unzip that apk under the lib folder you will see the only architecture it supports is armeabi-v7a. Compared to that this plugin supports 7 architectures. You can use the solution I provided above to choose which architectures you want to support

Cheers, Chris Neutrinos