Reduce apk size - android

I am developing an android application in which there are hundreds of high quality images(512x512px to 1000x1000 px and above) and hence the apk size has become too (more than 400mb) large. So, is there a way to compress my .png images or any other way to reduce the app size. I also read about proguard but will it delete my images?
Thanks in advance!

An APK with 400 MB is really huge, so you need to compress images, use these links to compress http://www.tinypng.com http://www.compresspng.com http://www.punypng.com You could also choose to load the images from server and store it in sdcard on application launch. So your application doesn't need to store images inside itself. I recommend you to store & load images from server.

You could try to use something like pngcrush, to reduce their file size, or you can try to store them remotely on a server and pull them down to the device on demand and cache them (it's likely that you don't need all the images at the same time)

How to reduce apk size-
Image Compression
Pre-process images-Manually optimize images in res folder using external tools, and set cruncherEnabled to false to keep optimization.
Pre-process .PNG using zopflipng.
In android version above 4.0 WEBP images can be used.
For icons vector drawables is better option.
Code Compression
-Use proguard to compress the bytecode in raw apk file.ClassyShark is apk explorer tool allow to look into dex files
Remove resources using resConfigs.
Set shrinkResource true in build.gradle file to remove unnecessary resources left by proguard.
ArscBlamer is tool to compress strings.(For apps which have multiple string folder for multiple android versions)
for more info about apk size visit this link

As stated in earlier answers there are ways to compress images, but these will not take you too far. You need to change you app to dynamically download images. To save space on the user's device, you should probably let users pick which images or groups of images they want to download, instead of downloading all images.

Related

How to use 100's of different .gif images in Android Studio

I've 100's of .gif images to be used in a android application that I'm trying to build. Can any one suggest me how should I minimize their size. And should I place them in drawable directory.
Google play has a limit on APK size which can be uploaded to playstore(if I am not wrong its 100Mb), so having so many .gif files inside application drawable folder will not be a solution.
Best solution I could think of right now is via Dynamic asset delivery by google play.
Please go through below for more info on asset delivery
https://developer.android.com/guide/app-bundle/asset-delivery

Reducing the size of some pdf files

I am adding some PDF files in my android application but these files are about 100 MB. This increase my application size a lot. is there any way i can reduce the size of my application and make it memory efficient?
Reduce the image size in your pdfs: this is more correlated to pdf
than Android I think. Use something like Acrobat Reader Pro, or
Photoshop to edit the images and make the .pdf.
Instead of embed the pdf file on apk, provide an external link for
the file hosted on somewhere (onedrive, google drive...), so the
file will be downloaded on the fly by user.
Compress the pdfs in some .zip file and embed this file on apk.
Then, when the user open the app for the first time, you extract the
pdfs on internal/SD storage. I'm not shure if this will be so
effective due compressions reasons that depend of the type of file
beem compressed.

Android APK Raw File Size vs Download Size. How to shrink the Raw File Size?

I'm using Android Studio 3.0. When I Analyze my APK, I see the following
Raw File Size: 4.1 MB, Download Size 3.3 MB.
Why is that different?
Since this is an Instant App, it prevents it from being uploaded. How could I shrink the Raw File Size without need to change my code/resource that is needed on download?
The APK Analyzer provides two sizes for each file which is packed into your APK, as well as overall for each 'directory', including total. These sizes do not indicate the compression that you got when the APK was created (APK format is ZIP compatible, so you can use unzip -lv qqq.apk to examine what effect this step had for squeezing the total).
For the end users, both sizes actually matter. With smaller Download Size, they get your app faster, and waste less off their data plan. With smaller Raw Size, the APK takes less space on the user's device.
But there are some tiny details to take into account. Let's take for example the native libraries (if your app uses NDK).
First of all, consider application update. Google Chrome team found that if they don't compress the native libraries, app updates become quite a bit smaller. If you multiply this gain by the number of expected app updates, this gives a major advantage.
Second, if you don't compress the native libraries, you can actually reduce the disk consumption of your app (for Android Marshmallow and above), because then, the libraries can be loaded in-place, without being unpacked to /data/data/your.app.package/lib.
Luckily, all this is managed by simply adding an attribute:
android:extractNativeLibs="false"
to the application tag in your AndroidManifest.xml file.
Same considerations may be applied to the assets: AssetManager can load them from inside the APK, without need to unpack them to disk - if the asset is not compressed in the APK.
APK Analyzer will show you how Google Play will squeeze such assets for download.
From the documentation:
Raw File Size represents the unzipped size of the entity on disk while Download Size represents the estimated compressed size of the entity as it would be delivered by Google Play.
So the download size will almost always be smaller than the raw file size as Google Play does additional compression as it delivers the binary over the network.
There is no silver bullet to reduce raw file size, it's a matter of looking at where the space is being used within the APK and working out what you can remove. The docs have a fairly in depth guide to doing this.

How to store the all jpg pictures that I've used in program

I want to implement an art game android application in Android Studio. But I'm confused about how to store the pictures? There will be 100 or more pictures of art works in game. The idea came to my mind is to minimize the sizes of pictures and adding them in drawable folder. Is there any efficient way to do that?
Thanks
First of all use TinyPng to compress your images without loosing ANY quality, I said ANY and I mean it.
and second don't put them in drawable because android will increase there sizes when you will generate signed APK, instead you should put them in raw directory which you can create in res directory, like res/raw.
Raw directory works same as drawable and any files in this directory gets resource Ids just like drawables so you can access files in it just like R.raw.yourimage.
I work on applications which includes hundreds of images and this is the best approach I have used.
Hope it helps.
If you are concerned with the space the 100 images takes up you could use a tool like photoshop or similar so compress your images to desired size (publish to web in photoshop).
Other than that I dont see why you shouldnt just save them in a drawable folder.

Compress large number of pictures to be packaged with app

I want to package large number of pictures, almost 90 mb with my app.My initial implementation was to download the image whenever required but then it was causing unnecessary wait and is spoiling the experience.Is there any way to compress the app with the apk? Otherwise any suggestions from experience how to handle this situation? Also is if i ask user to download image set on sd card on first run, will i face any issues if i want to update image(i.e change some images).
First of all, you may find this Android blog post useful. You can assign huge expansion files (up to 2 GB) to you .apk, so you might as well put those images there. However, I'd certainly be upset as a user if I had to download that 90 MB again when you decide to update those images.
As an alternative, you could just .zip those images up, and if you can crank the overall app. size below the 50 MB limit, you could store it as a project asset. And you could unzip those images onto the SD card on the first run. But then again, updating the images is problematic.
Why do you consider on-demand downloading a bad approach? Your app could download those images as needed, and cache them on the SD card. You could also limit the cache size. I'd definitely go that way. Updating the images is straightforward opposed to the static way of embedding huge .zip files in your project's assets, or using expansion files.

Categories

Resources