I'm currently working on an app which downloads a zip file and extracts a bunch of tiny mp3 files into external storage. The zip file is about 2.5 meg.
I'm wondering if it would be a better idea to include the zip file in app resources, and then copy and extract it to the file system. This would prevent the headaches involved in something like a lost connection during the zip file download. I noticed some missing mp3s, and when I checked the zip file, the last 20 or so weren't it it. So, it looks like the system can successfully (an unfortunately) extract from an incomplete zip file.
The downside including the zip file in app resources is obviously that it increases the size of the app by 2.5 meg. I've specified "prefer external storage" in the manifest. This isn't supported before release 2.2, i.e. level 8, so I'm already excluding those phones, which probably is 20 or 30 percent of the total android phones. But I'm not entirely sure if that guarantees the app will be installed on the SD card.
It could be worth including the zip file in the app just to avoid the potential hassles in handling the download of the zip file; but if the size of the app makes it unappealing, then that's kind of a drawback - especially if the "prefer external" doesn't work on some devices.
Which is the better option? Ideas are welcome.
One of the highest selling Android Games, Gun Bros, does what you are thinking about: small app, that downloads the content on demand. This allows them to also serve ads while the content is downloading. In addition, by downloading the content you can make use of compression over the network thus reducing the total amount of data a user will actually have to use to get the whole application. I think in the end it is a personal preference, but I would lean towards downloading over the network.
Given the fact that there are some apps/games out in Android market which are in the 40+ MB range a 2 MB additional download doesn't seem that much to me. Anyway your users have to download it one way or another. Either in the apk or as a separate zip file.
Now Android market allows you to post updates to your application so your users can get new content through there.
Regarding prefer external storage, it is just that - a preference. If external storage is not available or a user is installing it on a 2.1 phone, then it will install the application to internal storage, as long as your applications minimum SDK level is 7 or lower.
But there are other applications I can think off that download content from sites, things like scripting for android (SL4A). If you want to update your game content that way, I would recommend creating a mechanism whereby your application can first discover the size of the download, then do the download. And once the download completes, verify the size against the size it should be. If the two don't match, then run the download again or something like that.
I'd recommend just including it in the apk file. Many apps on the market are like 5-10 MB, and games can be even bigger (I've seen games range anywhere from 1 MB to 40 MB), so adding 2,5 MB to your app shouldn't really be a problem, even if they don't support installing to sd-cards.
My phone for example have 2.1 and therefor can't install to the sd-card and I've so far never run out of space even after installing a bunch of 2-5 MB apps.
And no "prefer external storage" does not guarantee that it's installed on the sd-card, if the user doesn't have an sd-card for example, or if they choose themselves to move it to the internal storage.
Point is, adding 2,5 MB to your apk isn't anything anyone will really notice or care about, and you shouldn't need to either.
Related
As you all know a disadvantage of Xamarin Forms apps is their huge size. Though I went through different scenarios for reducing app size such as Linking and using Proguard, my Android APK size is still so high(about 30 MB). The thing is when I compressed this apk by Winrar the size got to about 11 MB. I renamed this compressed .rar file to .apk file but when I tried to install this file I got the message: "There was a problem parsing the package".
So my question is is there any mechanism to leverage the compression of a tool like winrar for an APK file so that it could be installed on any Android device?
Unfortunately, this isn't that easy.
During the packaging process, your app archive will be hashed. If you rar it or do any other tampering with the archive, the resulting app archive will have a different hash than the one it was built with. This will result in your apk invalidating itself on install due to security reasons.
You are going to have to unpack it then on the device again. You can't just go and rename a file and expect it to work, the binary structure is completely different.
You will need the user to download an app that is capable of unpacking a .rar (or whatever format you decide on) and learn the user to extract the APK file from there and then install it. The you do need to take into account is that the user needs to be a bit tech savvy to be able to do this and in some cases might even need more rights on a device than is usual. As far as I know there is no delivery mechanism that does this for you.
If you ask me, 30 MB isn't that much and the trouble to go through all this isn't worth the few megabytes you shaved off. If you look at the average apps in the store they are easily bigger than that.
I'm expecting suggestions for the concept related to APK Expansion Files in Android.
Google Play currently requires that your APK file be no more than 50MB. For most applications, this is plenty of space for all the application's code and assets. However, some apps need more space for high-fidelity graphics, media files, or other large assets. Previously, if your app exceeded 50MB, you had to host and download the additional resources yourself when the user opens the app. Hosting and serving the extra files can be costly, and the user experience is often less than ideal. To make this process easier for you and more pleasant for users, Google Play allows you to attach two large expansion files that supplement your APK.
Does apple give any support like this?
In my case I have 180MB audio file, I don't want to keep that with app resource. After installation I want this download from APPLE store.
I can able to keep this in my server and download when app opens first time, but I would like to know is there any other way to supplement for iPA.
Thanks InAdvance.
The maximum size of your ipa could be up to 2GB. For sizes upper than 50mb will be downloaded through WiFi or from iTunes. ipa less than that could also be downloaded through 3G network.
Try to make your app size as minimum as possible as users don't really like apps with larger size..
Well there's no thing here in iOS like APK Extension Files in Android.. Everything is your one single ipa which is compressed form of your binaries and resources.
Apple doesn't offer a facility for this specific use case.
You'll have to download the content when your app starts for the first time. Remember to store it in the caches directory or set the "do not backup" flag on the files. This is according to Apple's guidelines and required for app review. If you store it in the Caches directory, iOS may decide to delete the data when disk space is low, so be prepared to download it again if it doesn't exist when your app starts.
Unless you're using in-app purchases and targetting iOS 6 users only, you'll have to host it on your own servers. In-app purchases cannot be free.
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?
My app has several image and media files, which are around 1MB each or so. So if i follow the normal way, the app size is crossing over 40MB, which is huge. Is there anyway to avoid this?
I have heard of external storage, but i really don't get any clue of how to work on them!
Do i need to ask all those who instal this to save the images and media files in the external disk and then the app uses those? This makes my files public..isn't it?
I actually don't own a android device. So is it like, whenever people install an app from the market, does it ask if it has to install in the phone memory or the external memory?
I really need your help.
If there is a way, i'd be thankful if you can provide me the step by step details of how this can be done!
Thanks a lot..
Regards
Nithin
There is, from the little I know of this, a slight security risk from putting files onto the SD card. I don't think I personally would worry too much about that since most people that would want access to the files in your apk (Which does not include your source code) could get it regardless without too much trouble.
As of Android 2.2 the user has the option to move an app to their SD card, but only if the developer explicitly tells the app to allow it. I'm fairly sure this only applies to 2.2+ devices though, so being that you are likely going for a larger audience than that it isn't an end-all solution. I am only really pointing this out in case you do end up putting one large file on the market. If so, be sure to allow the transfer to SD card, your app will stay on devices much longer.
Downloading the files online from within the app and saving them out to the SD card would be a good solution, though I am not sure how end users feel about downloading a small app then having to download a very large package before using it. In the end they will have to download it either way, so it is up to you whether you want to ask them to do it up front in the market or afterwards via the app. If you do want to try to download all the content then maybe the code example in this link will help you figure it out :
http://androidsnips.blogspot.com/2010/08/download-from-internet-and-save-to-sd.html
You might consider streaming the files or downloading them inside the application to the sdcard. Speaking from experience my users have had problems downloading apps as big as 30MB. Some phones also have a severely limited internal memory, which is where the applications are downloaded to.
I have 2 binary files that i would like to package with my apk. (/res/raw)
i need to copy these 2 files to /sdcard when the application is run
how can i do this?
We have the same issue ... the direction we are exploring is to have two separate installs - the first one is the app and the second one is the data-app. When the data-app installs it copies the binary files to the SD card. When we uninstall the data-app it frees up the internal storage.
We don't have this one completely licked yet, and would love to hear other input and maybe find someone to help us by writing a couple of skeletal sample applications for us.
There are so many people who are in this boat (based on my googling) that if this approach doesn't work I suggest we (or someone) set up a generic file delivery web server and generic file delivery Android service and make it available to developers for a very low cost.
You need to use the AssetManager.
That will give you can InputStream that you can copy to a FileOutputStream.
It all depends on what your goal is by doing this.
Are you trying to be nice to the user and conserve disk space on the device by moving files to the sdcard? Or do you merely want to ensure that these files are on the sd card?
If you just want to put the files on the sdcard then you should use the AssetManager as CaseyB mentioned
If you are trying to conserve phone memory then consider distributing the apk file without the 2 raw files, and then on first run download the files from a server that you have set up. This may cause a bit of a problem due to the time needed to download the files, but some users on devices with limited memory available on the device itself will be appreciative of it.