Android' Spinning Wheel'应用程序在启动时崩溃

时间:2015-04-27 18:06:08

标签: java android android-manifest logcat spinning

我从一个关于纺车的教程中获取了代码 我已经根据我的应用程序调整了代码,但由于某些原因导致代码崩溃,我无法弄清楚原因。

我真的很感激任何帮助。

logcat信息是:

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)

2 个答案:

答案 0 :(得分:0)

您是否尝试使用较低的值初始化字节? 有时,手机的内存无法处理如此高的va。梅毒。

答案 1 :(得分:0)

听起来像你的动画图像太大了。每种可绘制类型都有单独尺寸的图像? hdpi,mdpi,xhdpi等...

如果需要,请使用Android Asset Studio缩放图片。