Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apk size increases after plugin installation #45

Closed
yashashri10 opened this issue Feb 13, 2019 · 5 comments
Closed

Apk size increases after plugin installation #45

yashashri10 opened this issue Feb 13, 2019 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@yashashri10
Copy link

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
Copy link
Collaborator

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"
        }
    }
  1. 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

@ChrisTomAlx ChrisTomAlx self-assigned this Feb 14, 2019
@ChrisTomAlx ChrisTomAlx added the question Further information is requested label Feb 14, 2019
@yashashri10
Copy link
Author

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

@ChrisTomAlx
Copy link
Collaborator

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
Copy link

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
Copy link
Collaborator

ChrisTomAlx commented Mar 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants