Android - Media Player - Opening an audio stream crashes the app

I’ve been developing a simple app and I’ve been struggling with using the media player. I test my app builds on Bluestacks and the app does function, but when I load it onto a device it will crash everytime the media player opens the stream.

On the Pre-launch info on the android dashboard it says that the device is running out of memory.

Issue: java.lang.OutOfMemoryError: Failed to allocate a 1048588 byte allocation with 251960 free bytes and 242KB until OOM

I know this is due to the media player as I’ve managed to isolate it by loading it manually through a button press, as it will hang on Bluestacks and then play, whilst on device it outright crashes.

Could this be to do with Garbage Collection? Has anyone encountered anything similar and managed to resolve it?

All the posts I find are mostly to do with the media textures and the solutions don’t seem to work for me.

My set up is as followed:

Could this possibly be to do with the streams bitrate? I’m not sure what the current streams bitrate is but apparently that can cause out of memory issues?

So it turns out it IS the bitrate causing it to crash. If you are struggling to stream audio on mobile devices then make sure you have an acceptable bitrate. I know that lower bitrates reduce quality but there’s only so much the mobile devices can handle.

I’m not sure what the best bitrates are for streams on mobile BUT this link should provide some insight on the matter:

link text