位图工厂错误
Bitmap factory Error
您好,我一直在尝试在 Eclipse 中开发一个简单的游戏,我正处于尝试添加背景图片的阶段,但是当我尝试 运行 应用程序时,我得到了 "unfortunately has stopped working"查看日志猫,我最好的猜测是下面的位图工厂行有问题:
background = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.underwater), ScreenWidth, this);
这是我收到的日志猫:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:406)
at com.example.deepseadiver.GamePanel.<init>(GamePanel.java:21)
at com.example.deepseadiver.Game.onCreate(Game.java:69)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access0(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
非常感谢任何有关如何解决此问题的帮助或建议。
更新清单文件,在应用程序标签内设置大堆 -
.
.
<application
android:largeHeap="true"
. .
>
....
</application>
您好,我一直在尝试在 Eclipse 中开发一个简单的游戏,我正处于尝试添加背景图片的阶段,但是当我尝试 运行 应用程序时,我得到了 "unfortunately has stopped working"查看日志猫,我最好的猜测是下面的位图工厂行有问题:
background = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.underwater), ScreenWidth, this);
这是我收到的日志猫:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:406)
at com.example.deepseadiver.GamePanel.<init>(GamePanel.java:21)
at com.example.deepseadiver.Game.onCreate(Game.java:69)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access0(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
非常感谢任何有关如何解决此问题的帮助或建议。
更新清单文件,在应用程序标签内设置大堆 -
.
.
<application
android:largeHeap="true"
. .
>
....
</application>