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.
Related
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.
In my Travel app which depends on lot of images. I have implemented a Lazy Loader and Caching of images. In total for all the destinations the images are close to 20mb. If a User wants to download all the Images so that he can still access the app offline. How can i make sure the caching of the files work with the downloaded image files.
There are two possibilities for your app, depending on what exactly you are wanting to do. Feel free to read more about this at the Android Docs.
Internal Storage
This directory persists, and is private to your application. It might have limited space, especially for older devices.
SD Card
This will have much more space, but will be accessible to the user and other apps. You could store information in your private storage to verify the integrity of this data. You will need a permission to write to the card.
I would suggest you choose one of these two, and store your data there. This should persist from run to run. Perhaps you could even include a function that would "Pre-cache" all of the files to the appropriate folder. 20 Mb isn't really that much space, you could even include it in your app itself. It's all up to you.
I've been developing this content-based app for Android which includes over 120 MB of video .mp4-files saved on the raw folder and in addition it includes over 20 MB of sound files also saved in the raw folder.
The problem is I cannot install the app on my Android phone due to limited internal memory to handle all those files. Also, I read somewhere that the app size limit on the Android market is 50MB so I won't be able to even upload the damn thing.
I've saved the videos on the raw folder as I was able to play them fine (using VideoView).
My question is how do i cope with such size, do I have to go through making the user download the content after installing the app or is there any other way of dealing with such sizes (~140 MB).
You cannot distribute an APK through the market that is more than 50MB. Its not a good idea to take up 120MB of the internal storage for a single app as many phones don't have a lot of internal storage space.
You should consider stripping out all of the large files, hosting them on a server and then having the application download the files on the first launch. I would also recommend you save the files to the SD card so you don't use up too much of the precious internal storage.
Edit: I will admit that any time an app tries to download a lot of data on the initial launch I get really frustrated. Make sure you do it in a way that doesn't require the activity to be open the entire time the file is downloading. Do the downloading through a service so the user can at least use their phone while your app is downloading the media files.
Well, if you're sure you need all this content inside your application, the only solution I see is to download the content from a server when the application is opened for the first time. But as a user I think I won't be very happy to have a 150 Mb application on my phone. Do you really need all this data?
I have approximately 80MB+ mp3 files,40MB images in my project.when I try to put 3MB of each these files eclipse takes a lot time to build.is it possible to put all these files in Raw or assets folder?what is the solution to make eclipse build fast.
I think for best practice is to make the user download these files after he installes your app since Android market limits your app size to 50MB.
You can use
AsynTask to download the data asynchronously
I have this same issue, and came to the same conclusion as khr2003. I just want to add that the real limit for Android Market is more like 30MB since an app larger than that is impossible to download to most phones -- you will get out of storage errors.
I have 11 videos to include in my App. Each of them is around 9MB. Besides those, I have to a few sound files and image files in the app. Therefore the app size is going 100+MB. Is there any way to accommodate all the files so that app size does not become an issue for me?
Download the files after starting the app for the first time.
Puh..that's quite large. In such a situation I'd
Let the user download your app not containing any videos/audio files that cause the large size
At first run guide the user through a wizard where you download the additionally needed files to the SD card.
Still, downloading nearly 100MB won't be ideal, but better than directly download all of it at the first install. (IMHO)
The most common sollution i've seen is downloading them during the first run of the programme. Just check if everything is available, and if it isn't, download the needed files.
pros:
This way you can also add video's on the fly.
APK size stays small so initial download is quick
Cons:
after downloading the app you can't directly use it: content must be downloaded first
I would suggest you to put them in the assets folder, so they will not be compressed.
This way you'll have problems testing your project with eclipse, so try building it with command line, and then install on device with adb
In my scenario, I had 300+ videos, totalling upto 400+ MB of the size.
I checked with few of them and deployed the app the way i just told.
may not be the best way around, but may work.
You can upload into youtube or make your own simple video streaming server