-1

I've taken a code from a tutorial about a spinning wheel.
I've adjusted the code to work from my application but it's crashing for some reason and I can't figure out why.

I'll really appreciate any kind of help.

The logcat information is :

com.truthordareyakir.android.truthordare E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.truthordareyakir.android.truthordare, PID: 2404
java.lang.OutOfMemoryError: Failed to allocate a 37748748 byte allocation with 4194304 free bytes and 27MB until OOM
        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
        at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
        at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
        at com.truthordareyakir.android.truthordare.MainActivity.onCreate(MainActivity.java:45)
        at android.app.Activity.performCreate(Activity.java:5937)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
        at android.app.ActivityThread.access$800(ActivityThread.java:144)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Yakirbu
  • 182
  • 1
  • 3
  • 14

2 Answers2

0

Have you tried to initialise the byte with a lower value ? Sometimes the Memory of your phone can't process such high va. lues.

avk
  • 871
  • 1
  • 9
  • 22
0

Sounds to me like your animated image is too large. You have have separate sized images for each drawable type? hdpi, mdpi, xhdpi, etc...

Use the Android Asset Studio to scale images if needed.

Gary Bak
  • 4,746
  • 4
  • 22
  • 39