Just How To Decrease Android APK Dimension

Android application Dimension truly matters when going real-time to the play shop. Individuals frequently prevent downloading and install applications that appear also huge, specifically in arising markets where gadgets link to often-spotty 2G and also 3G networks or work with pay-by-the-byte strategies.

I wish to share minority techniques which you can make use of to lower apk dimension without influencing the top quality of your application.

1. ProGuard

ProGuard is one of the most famous booster for Java bytecode. It maximizes bytecode and also gets rid of extra directions. It relabels the courses, areas, and also approaches utilizing brief worthless names that makes code more secure from reverse design. It makes your Java and also Android applications as much as 90% littler and also as much as 20% quicker. You can find out more regarding proguard https://www.guardsquare.com/en/proguard.

To allow proguard:
Open build.gradle data in android workshop and also include minifyEnabled real and also shrinkResources real.
Yet bear in mind diminishing procedure of code reduces the moment of construct. So you ought to just utilize it when you are mosting likely to launch your application or if you are offering it for screening.


minifyEnabled is accountable for diminishing your code data (e.g. Java). It is the highlight of ProGuard, and also aids to reduce your APK along with making it challenging to turn around designer.

shrinkResources is made use of to eliminate extra source data (such as pictures and also various other possessions). For instance, if you are assembling with an Android collection, however you are not utilizing some pictures because Android collection, they will certainly not be consisted of in the last construct.

2. Vector Drawables

As the name suggests, vector drawables are based upon vector graphics, in contrast to raster graphics. It resembles SVG data. In Android Vector Drawable are developed with XML data. Prior to the Enhancement of Vector Drawable in Android SDK, designer needed to develop several variation of pictures for various screen resolutions. This take even more time to develop added possessions and also eat even more room that raises the Apk dimension.
Currently there is no requirement to create various dimension picture for mdpi, hdpi, xhdpi and also etc. With Vector Drawable you require to develop picture just when as an xml data and also you can scale it for all dpi and also for various gadgets. This likewise not conserve room however likewise streamlines upkeep. You can find out just how to develop vector drawables http://www.androidtutorialshub.com/android-vector-drawable-example-using-appcompat-support-library/

3. Google Play Provider

Select the assembling APIs thoroughly.
In variations of Google Play solutions before 6.5, you needed to put together the whole bundle of APIs right into your application. In many cases, doing so made it harder to maintain the variety of approaches in your application (consisting of structure APIs, collection approaches, and also your very own code) under the 65,536 restriction.
From variation 6.5, you can rather precisely put together Google Play solution APIs right into your application. For instance, to consist of just the Google Map and also Android Put on APIs, change the complying with line in your build.gradle data:

with these lines:

Below you can see discover even more Api’s of Google Play Providers:- https://developers.google.com/android/guides/setup

4. Apk divides

You frequently construct a solitary APK to sustain all your target gadgets whenever feasible, that may lead to a huge APK as a result of data required to sustain several display thickness or Application Binary User Interfaces (ABIs). One method to lower the dimension of your APK is to develop several APKs which contain apply for particular display thickness or ABIs. Gradle can develop different APKs which contain just code and also sources particular per thickness or ABI. To find out just how to configure your construct to create several APKs follow this web link https://developer.android.com/studio/build/configure-apk-splits.html

5. Enhance png pictures

An excellent method to boost the efficiency of your application is to enhance the dimension of your pictures. Smaller sized picture dimensions need much less memory use, disk room, tons time and also crucial lower Apk dimension. PNG pictures can be decreased in data dimension without shedding top quality. To do this, make use of a device such as OptiPNG or PNGCrush. Both are wonderful for minimizing PNG data dimension while still making sure picture top quality. You can likewise make use of some on-line picture optimization solution TinyPng

6. 9-patch pictures

A 9-patch png is an unique layout for PNG that can be made use of for histories. 9 spot pictures are specifically beneficial when making switches. As opposed to specifying a normal bitmap to be made use of as a history, a 9patch specifies 9 sectors– for each and every of the 4 edges, the 4 sides, and also the centre. For more information regarding 9-patch picture https://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
and also to find out just how to attract 9-patch device is a WYSIWYG editor consisted of in Android Workshop https://developer.android.com/studio/write/draw9patch.html

7. Advised Media styles

Long times applications are greatly reputable on pictures, sound or Video Clip so an additional method you can lower the APK dimension is by utilizing particular media styles. It is extremely suggested that you make use of the complying with media styles for pictures, sound and also Video Clip
Pictures: PNG or JPEG. Usage PNGs, considering that it is a lossless layout it is extremely appropriate for structures and also art work as there will certainly be no aesthetic artefacts from the compression. If there are room restrictions, make use of JPEGs or a mix of PNGs and also JPEGs. A top quality JPEG picture might function great for huge photo-realistic pictures, which the JPEG compression system is optimized for.
Sound: AAC Sound is suggested for all audio sources. AAC accomplishes far better compression at an offered top quality, contrasted to mp3 or Ogg Vorbis. Raw styles such as WAV ought to never ever be made use of. The typical sensible for utilizing the WAV layout is that translating pressed audio streams generally implies high latency at playback. Nonetheless, Android offers the Noise Swimming Pool API which makes it possible for applications to make use of pressed audio streams without the charge of high latency.
Video Clip Usage H264 AVC. Inscribe the video clip to a resolution no bigger than the display resolution of the target gadget (if understood).
Know extra regarding Supported Media Formats by android https://developer.android.com/guide/topics/media/media-formats.html

8. Reuse Resources

Recycling things is possibly among the initial vital optimization you find out when beginning establishing on mobile. It will certainly not also lower your Apk dimension however likewise conserve your time to establish the exact same point time and again.
For instance You can consist of a different source for variants of a photo, such as colored, shaded, or turned variations of the exact same picture. Yet It is suggested, that you recycle the exact same collection of sources and also tailor them as required at runtime.
Android offers a number of energies to alter the shade of a property, either utilizing the android: color and also tintMode features on Android 5.0 (API degree 21) and also greater. For reduced variations of the system, make use of the ColorFilter course.
The complying with code fragment offers an instance of transforming an “expand” arrowhead right into a “collapse” arrowhead symbol by merely revolving the initial picture 180 levels:

(***** )9. Eliminate Debug Details(****** ).

It is extremely suggested that you eliminate all debug-related capability from the application. The application typically does not see or utilize this information, and also the Android os does not need it to run the application. For this reason, the debug details just throws away room, and also ought to be gotten rid of.(**** ).(***** )10 Dust device

(*** )Proguard maximizes the java code just. However, it does not views on the sources side. As an example if you have actually a photo called icon_arrow. png in res/drawable and also it is not made use of anywhere, Proguard just eliminates it’s referral in the R course however maintains the connected picture in position.(******* )The dust device, a fixed code analyzer consisted of in Android Workshop, spots sources in your res/ folder that your code does not referral. When the dust device uncovers a possibly extra source in your job, it publishes a message like the copying.

These are tiny points and also I make certain it will not take much of your time to apply. Yet, in the long run, you would certainly finish with a leaner application dimension and also certainly a smile on your face. Please do not hesitate to comment if you have more recent strategies along with ask concerns. As well as, yeah! If this message aids you please do share!

Take Pleasure In Coding and also Share Expertise

You May Also Like