Actually, I am trying to create a app with n number of multimedia files which includes images and videos. My apps size is around 34MB
, and my assets size is aro
It's a common error when you dealing with Bitmap
so add this line in AndroidManifest.xml
:
android:largeHeap="true"
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:largeHeap="true"
android:hardwareAccelerated="false"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
Hope it will be helpful.
Simple Solution which I found is,
Add hardwareAccelerated
& largeHeap
under application
AndroidManifest.xml
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
This is happening because of large size image. Try with small size image i.e. of your phone screen resolution.
I had the same problem. Tried reducing the image size in Paint with 2100 x 1300 px and it worked but the app was lagging very much.
It sounds like you are either caching too many files in RAM or instantiating the same bitmaps and videos over and over until you run out of memory.
You should not write your own image loading and caching code on Android in 2016 unless you have unusual requirements. Use one of the libraries that have solved this problem. See Picasso v/s Imageloader v/s Fresco vs Glide for more guidance.