AsyncHttpClient download large Pdf files out of memory error - android

I'm building my first Android app and have run into a little problem. Using AsyncHttpClient to download Pdf files I get
"E/dalvikvm-heap(30871): Out of memory on a 21893326-byte allocation."
errors on anything larger than 15 Mb. Files up to 15 Mb download just fine. Are there any settings that can resolve this?
Thanks in advance for your help!

Are there any settings that can resolve this?
Not really. Assuming that you are using BinaryHttpResponseHandler, it will give you the entire file in memory, which will not be possible for larger files.
You would need to create your own version of BinaryHttpResponseHandler with a modified sendResponseMessage() method, one that streams the results directly to a file. Or, find another HTTP client library that does this for you.

Related

download and add resources eg.layouts, drawables dynamically to app in android

Here is the thing,
I want to download resources from the Internet and add them to my application.However, I have searched a lot and did not get a solution.So, Finally asking you guys, Please help!!!!
Findings:
I can load java code with dexClassLoader.
I can not not use APK extension file.
I dont want to access resources from another APK. Because then I need to ask user to install one more apk.
If I download resources just like an image file and try to use bitmap,Will it be too slow for my app.
Please do not say "NO its not possible".Will any hack do this???
I want to download resources from the Internet and add them to my application
You are certainly welcome to download files and use them. You cannot download resources as defined by the Android SDK, as those have to be compiled into the app.
I can load java code with dexClassLoader.
This has security ramifications. I do not recommend this.
If I download resources just like an image file and try to use bitmap,Will it be too slow for my app.
Many Android apps download images from the Internet.

Can't transfer files from emulator > 2 MB

I am trying to transfer files from my android emulator to my server. I observed that files of size around 2MB or greater are just not getting transferred.
Is it because of the internal memory I've provided to the emulator. If it is, should I change the way I'm transferring the file? My transfer method is similar to the only here: Android:How to upload .mp3 file to http server?
Yes, I found the answer. I had to make a change in the PHP ini file and increase the limit to my desired size :)
So there is nothing wrong with the emulator as such, it was a problem at my webserver end.

80Mb mp3 files+40 MB images,what is the best place?assets or Raw?eclipse takes time to Build?(android 3.0)

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.

Android App size problem

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

How to store around 12MB of MP3 files in res/raw folder of my Android 2.3 Project?

I am developing a small application in Android 2.3 using Eclipse 3.4 IDE, I wish to store more than 200 mp3 files in the res/raw folder of my project.
But Wen I started the Android Emulator,it stop working by showing this message in console:
"INSTALL_FAILED_INSUFFICIENT_STORAGE"
Please tell me a way out from this problem
I think the error is explicit enough. The app is too large in size for the internal storage.
I think it's time to redesign your app. For instance you can download the mp3 file from the network on demand and then save it to the sdcard.
BTW, if you plan to support just Android version > 2.2 you can add android:installLocation="preferExternal" into your manifest file and this should rid the problem
Decreate the bit rate of mp3 files! I think 8bit could be fine if you predict that a user will not listen your mp3s via external speaker.
If you have files that will be listened via external speaker, than decrease bit rate in all files except in those.
If you cannot use any of these actions, then you made a big mistake in an application design.
PS. if it's not a secret, could you tell me what kind of app needs 200 mp3 files?
Do you have to use MP3? Android docs suggest you should use OGG where possible.
The Installation of this app was failed due to the insufficient storage space available in the Android Emulator.
And this was removed when I run the app in a new Emulator with sufficient amount of memory space available for successful installation of the apps.
Now this app is successfully running in the new Emulator. Thanks for your support.

Categories

Resources