Reduce size of .apk file when use native libraries in android without using pro-guard

how to reduce apk size in android studio
android reduce library size
how to compress apk file size
app size reducer app
proguard-android
reduce apk size react native
reduce android studio project size
app size reducer apk

I am developing a PDF related application in android (java). For PDF editing and converting others file type to PDF file, I add some native libraries and that work fine for me. But after developing an application, the released .apk file size is above 29 MB. If I apply pro-guard, the .apk size is definitely reduced as 22 MB. But I do not want to apply pro-guard because some functionalities do not work with pro-guard. So how can I reduce the size of my .apk file?

You should use SVG images

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability. It can be scaled without loss of display quality, which means the same file is resized for different screen densities without loss of image quality.

Vector objects are much smaller than raster image format. If we have full size image to update, the vector file might only take few kilobytes of space on your system, where the same image in medium resolution bitmap format might not place on CD ROM.

FYI

Use app bundle instead of apk.

Google Play’s new app serving model, called Dynamic Delivery, then uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.

Reduce your app size, Upload your app with Android App Bundles; Use the Android Size Analyzer You no longer have to build, sign, and manage multiple APKs to support An APK file consists of a ZIP archive that contains all the files that comprise your app. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.​pro' If your application supports many architectures, you can further reduce APK size by using APK splits, whereby each APK includes only one architecture. In release 100.5, ArcGIS Runtime for Android will support x64 architectures, adding more.so files to a single APK deployment.

one thing you can try is from Refactor>Remove Unused Resaurces it will remove unused classes,images,xml,etc so it will decrease some of your apk size.

And one more thing you can do is shrinkResources by adding shrinkResources true

as below in build.gradel

android {
    // Other settings

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true 

        }
    }
}

How we reduced our app size by 72% - Elvis Chidera, The classes.dex file which contains the app code (3rd party libraries inclusive) was While Proguard can help reduce the size of your classes.dex file by The Android build tool compresses the images in your APK already during is very legible and there is no pressing need to use something different. Reduce the size of native binaries If your app uses native code and the Android NDK, you can also reduce the size of the release version of your app by optimizing your code. Two useful techniques are removing debug symbols and not extracting native libraries. Remove debug symbols

There are multiple ways to reduce apk size. You can start using App Bundles which splits your app into base, configuration and dynamic feature apks based on architecture(native libs), density & language. When installing, it merges various configuration bundles and create a singular apk for that device using its specs.

This reduces download(install) and update size but final bundle(.aar) file is same as that of universal apk created without bundle.

Another option is to create Multiple APKs. This way you create and manage apks yourself by specifying densities, architecture and language you wanna support or ignore. This will be a little bit hectic but this certainly reduces final apk size as you are only using required resources and libs.

Both of these work in similar way but in case of bundles, you don't have to manage multiple apks yourself. You just handle creation of bundle, and play store will create apks itself depending on device requesting the update or install. But in case of multipole apk, you create all the apks yourself. E.g. If you support 3 languages (en, es, fr), 2 architectures (x86, x86_64) and 4 densities (mdpi, hdpi, xhdpi, xxhdpi), you will have to create 3x2x4 apks.

How to reduce your Android APK size and make it lighter, If you use AppCompat-v7 or support library-v4 in your app (which you probably do), make sure your ProGuard file doesn't have any of these lines. -keep class  When extractNativeLibs is set to true (default) or not added to the manifest, your native libraries can be stored compressed in the APK. They are extracted by the PackageManager during installation, and a copy is put to /data/app/. As a result, there are two copies of the native library - a compressed in the APK, and an uncompressed in /data/app/.

8 Ways to Reduce Your Android App APK Size, Since the Android Marketplace launched in March 2012, the size of the without dramatically increasing the size of your APK has long been a Once you've uploaded your app as an .aab file, Google Play will use ProGuard, add the following to your module-level build.gradle file: Powered by Native. AndroidManifest.xml: It has the core Android manifest file that lists the name, version, access rights, and referenced library files of the app. The file uses Android’s binary XML format. How to reduce Android app size or APK size 1.Remove unused resources, code, and classes

Understanding Android APK size | Help, Here are a few suggested strategies for reducing the final Android app APK size images, strings, and more can pile up, but your final APK might not use them all​. and set up necessary ProGuard rules if you're using other third-party libraries! build an APK file for each CPU, only containing the relevant native libraries. In this blog, we learned how to reduce the APK size by using R8 in our application. As the app size matters a lot. So, use R8 to reduce that app size and it is easy to implement. Hope you learned something new today. Have a look at our Android tutorials here. Do share this blog with your fellow developers to spread the knowledge.

Mastering Cross-Platform Development with Xamarin, In spite of the fact that most of the configuration values are disabled by default in a to bundle the application assemblies into a native shared library as a security Android application packages contain an executable bytecode file called the Enable ProGuard: ProGuard is another option that can help reduce the size of  Reduce Java and Native Code. Methods to reduce the Java codes are:-1. Remove Unnecessary Generated Code 2. Remove Enumeration 3. Reduce the size of Native Binaries: If your app is using native code and the Android NDK, you can also reduce APK size by optimizing the code. To do so there are two techniques which might be helpful:-

Comments
  • use bundle instead of apk for release.
  • There is not reduce the size of .aab file using android app bundle.
  • developer.android.com/google/play/publishing/multiple-apks: Particularly read the box at the top. Apparently Google Play will automatically minify the APKs for you.
  • @MehulDhimmar Solved this yet?
  • @IntelliJ Amiya... No, I am trying various ways but I am not success till now.
  • I do all as you mention above. I am having a problem with libraries size, not images.
  • @MehulDhimmar read developer.android.com/topic/performance/reduce-apk-size
  • @MehulDhimmar medium.com/vectorly/…
  • see his question
  • seen he want to reduce size of apk and I'm suggesting the solution.
  • Without proguard.
  • dear above solution is without proguard please check updated answer.
  • @yuvrajsinh, Your answer is to reduce size using pro-guard. but I do not want to add pro-guard.