I have tried this : OutOfMemoryError
And read many other such posts , but none of them worked
This is the error :
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.lud.root.jetfighter, PID: 19789
                  java.lang.OutOfMemoryError: Failed to allocate a 4940652 byte allocation with 2168368 free bytes and 2MB until OOM
                      at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                      at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                      at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:651)
                      at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:486)
                      at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1085)
                      at android.content.res.Resources.loadDrawableForCookie(Resources.java:2879)
                      at android.content.res.Resources.loadDrawable(Resources.java:2768)
                      at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
                      at android.graphics.drawable.AnimationDrawable.inflateChildElements(AnimationDrawable.java:324)
                      at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:294)
                      at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1220)
                      at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1129)
                      at android.content.res.Resources.loadDrawableForCookie(Resources.java:2874)
                      at android.content.res.Resources.loadDrawable(Resources.java:2768)
                      at android.content.res.Resources.getDrawable(Resources.java:932)
                      at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:133)
                      at android.content.Context.getDrawable(Context.java:465)
                      at android.view.View.setBackgroundResource(View.java:17566)
                      at android.support.v7.widget.AppCompatImageView.setBackgroundResource(AppCompatImageView.java:76)
                      at com.lud.root.jetfighter.Instruction.onCreate(Instruction.java:32)
                      at android.app.Activity.performCreate(Activity.java:6583)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1114)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2531)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2666)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1493)
                      at android.os.Handler.dispatchMessage(Handler.java:111)
                      at android.os.Looper.loop(Looper.java:207)
                      at android.app.ActivityThread.main(ActivityThread.java:5769)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
I/System: FinalizerDaemon: finalize objects = 381
Reading some other posts I came to know of large bitmaps exceeding the memory limit, but the files are too small to I think exceed the limit ( they are 8 to 12kB max .png files)
I have read many of the posts referring to the bitmap problem but none could help me.
I tried this :
android:largeHeap="true"
But since it didn't work , I read another article and it suggested to remove it , so I did it .
My Instuction.java file which runs into the error:
setContentView(R.layout.activity_instruction);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
ll = (LinearLayout)findViewById(R.id.instruction);
ll.setOnClickListener(this);
imv1 = (ImageView) findViewById(R.id.instruction_imv1);
imv3 = (ImageView) findViewById(R.id.instruction_imv3);
imv1.setBackgroundResource(R.drawable.inst);   // **This is where error occurs**
imv3.setBackgroundResource(R.drawable.collision); 
tap = (AnimationDrawable) imv1.getBackground();
tap.start();
collision = (AnimationDrawable) imv3.getBackground();
collision.start();
I loaded 22 files for the inst animation.
This is my inst.xml file:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/selected" android:oneshot="false">
    <item android:drawable="@drawable/enlarge001" android:duration="100" />
    <item android:drawable="@drawable/enlarge002" android:duration="100" />
    <item android:drawable="@drawable/enlarge003" android:duration="100" />
    <item android:drawable="@drawable/enlarge005" android:duration="100" />
    <item android:drawable="@drawable/enlarge006" android:duration="100" />
    <item android:drawable="@drawable/enlarge007" android:duration="100" />
    <item android:drawable="@drawable/enlarge008" android:duration="100" />
    <item android:drawable="@drawable/enlarge009" android:duration="100" />
    <item android:drawable="@drawable/enlarge010" android:duration="100" />
    <item android:drawable="@drawable/enlarge011" android:duration="100" />
    <item android:drawable="@drawable/enlarge012" android:duration="100" />
    <item android:drawable="@drawable/enlarge013" android:duration="100" />
    <item android:drawable="@drawable/enlarge014" android:duration="100" />
    <item android:drawable="@drawable/enlarge015" android:duration="100" />
    <item android:drawable="@drawable/enlarge016" android:duration="100" />
    <item android:drawable="@drawable/enlarge017" android:duration="100" />
    <item android:drawable="@drawable/enlarge018" android:duration="100" />
    <item android:drawable="@drawable/enlarge020" android:duration="100" />
    <item android:drawable="@drawable/enlarge021" android:duration="100" />
    <item android:drawable="@drawable/enlarge022" android:duration="100" />
</animation-list>
 
     
     
    