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 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 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
What's Oncreate(Bundle Savedinstancestate)
Add "View More" at the End of Textview After 3 Lines
Android: Change Shape Color in Runtime
Disable the Notification Panel from Being Pulled Down
Sniffing/Logging Your Own Android Bluetooth Traffic
How to Set a Particular Font for a Button Text in Android
Android Edittext - Finished Typing Event
How to Use Custom Permissions in Android
How to Use Getsystemservice in a Non-Activity Class (Locationmanager)
Drawerlayout Double Drawer (Left and Right Drawers Simultaneously)
How to Create a Resizable Rectangle with User Touch Events on Android
Android: Android.Content.Res.Resources$Notfoundexception: String Resource Id #0X5
Manually Put Files to Android Emulator Sd Card
Android: Can You Nest Fragments
How to Make a Phone Call Programmatically