How to reduce the apk size (App size too big)
Your problem is you are using many libraries, The worst of which being:
"com.github.barteksc:android-pdf-viewer:2.7.0-beta"
Libraries like this will be very hard to shrink and whilst there are many ways in other answers on how to reduce the APK size, this library is the main one you are looking for.
How to reduce App (.apk) Size
I would recommend that you compress the .jpg
files as much as possible, this should greatly reduce the size of your .apk
file. A tool such as Paint.NET which is free should help you do this. It has great resizing options.
How to reduce Apk (.apk) size in android studio
I solve this issue by adding this code in module app build.gradle file.
android {
packagingOptions{
exclude 'AndroidManifest.xml'
exclude 'lib/arm64-v8a/libcardioDecider.so'
exclude 'lib/arm64-v8a/libcardioRecognizer.so'
exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so'
exclude 'lib/arm64-v8a/libopencv_core.so'
exclude 'lib/arm64-v8a/libopencv_imgproc.so'
exclude 'lib/armeabi/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so'
exclude 'lib/armeabi-v7a/libopencv_core.so'
exclude 'lib/armeabi-v7a/libopencv_imgproc.so'
exclude 'lib/mips/libcardioDecider.so'
exclude 'lib/x86/libcardioDecider.so'
exclude 'lib/x86/libcardioRecognizer.so'
exclude 'lib/x86/libcardioRecognizer_tegra2.so'
exclude 'lib/x86/libopencv_core.so'
exclude 'lib/x86/libopencv_imgproc.so'
exclude 'lib/x86_64/libcardioDecider.so'
exclude 'lib/x86_64/libcardioRecognizer.so'
exclude 'lib/x86_64/libcardioRecognizer_tegra2.so'
exclude 'lib/x86_64/libopencv_core.so'
exclude 'lib/x86_64/libopencv_imgproc.so'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.paypal.sdk:paypal-android-sdk:2.14.1'
}
How to reduce size of an apk file?
When create new project from Android studio, the IDE automatically add some dependencies to your project.
dependencies {
// ...
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
// implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// ...
}
If you bundle support library
and constraint layout library
, your release apk size will increase rapidly even you don't add any code.
You can get a very small apk if you remove support library and constraint layout library and just use all the system api.
After remove the support library, you should
use
Activity
rather thanAppCompatActivity
,YourActivity extends Activity
do not use any theme from support library in your
AndroidManifest.xml
use
FrameLayout
to replaceConstraintLayout
in your layout
Android App apk size vs. install size and how to decrease them?
I use this method to decrease the apk size, you need to go to the build.gradle file and find a line that looks like that:
minifyEnabled false;
Change it to "true".
Add this line of code under:
shrinkResources = true
If you want to know more about this, see this Android Studio link: https://developer.android.com/studio/build/shrink-code
Also, to reduce more the apk size, upload your application as apk bundle to the play store, this will compress more the app.
Related Topics
How to Have the Code Pause for a Couple of Seconds in Android
Apache Httpclient Digest Authentication
Prevent Webview from Displaying "Web Page Not Available"
Convert a String to a Byte Array and Then Back to the Original String
Listview Viewholder Checkbox State
Android Drawable Speech Bubble
Android Httpclient Persistent Cookies
Java: Need Some Way to Shorten This Code
Java Apns Certificate Error with "Derinputstream.Getlength(): Lengthtag=109, Too Big."
Simple Sso - Using Custom Authentication - Cas or Some Oauth or Openid Server
Can't Run Junit 4 Test Case in Eclipse Android Project
Unhandled Exception Type Error
Android App Bundle Introduces Resource Not Found Crash in Android App
Proguard and Reflection in Android
Caused By: Java.Lang.Classnotfoundexception: Didn't Find Class in Firebase Phone Authentication