たくさんの画像があるAndroidアプリがあります。2.3 を除くすべての最新バージョンの Android で正常に動作します。これが私のコードです:
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
//mBitmap = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_4444);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
mRealPaint = new Paint();
mRealPaint.setAntiAlias(true);
mRealPaint.setDither(true);
mRealPaint.setColor(Color.BLACK);
mRealPaint.setStyle(Paint.Style.STROKE);
mRealPaint.setStrokeJoin(Paint.Join.BEVEL);
mRealPaint.setStrokeCap(Paint.Cap.ROUND);
mRealPaint.setStrokeWidth(12);
スタックトレースは次のとおりです。
06-30 15:10:53.252: E/dalvikvm-heap(987): 460800-byte external allocation too large for this process.
06-30 15:10:53.252: E/GraphicsJNI(987): VM won't let us allocate 460800 bytes
06-30 15:10:53.260: D/AndroidRuntime(987): Shutting down VM
06-30 15:10:53.270: W/dalvikvm(987): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-30 15:10:53.371: E/AndroidRuntime(987): FATAL EXCEPTION: main
06-30 15:10:53.371: E/AndroidRuntime(987): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.Bitmap.nativeCreate(Native Method)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.content.res.Resources.loadDrawable(Resources.java:1709)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.content.res.Resources.getDrawable(Resources.java:581)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.View.setBackgroundResource(View.java:7393)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.nova.picturepattern.common.view.DrawCharView.showStroke(DrawCharView.java:299)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.nova.picturepattern.common.view.DrawCharView.touch_move(DrawCharView.java:155)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.nova.picturepattern.common.view.DrawCharView.onTouchEvent(DrawCharView.java:230)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.View.dispatchTouchEvent(View.java:3766)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.os.Looper.loop(Looper.java:123)
06-30 15:10:53.371: E/AndroidRuntime(987): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-30 15:10:53.371: E/AndroidRuntime(987): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:10:53.371: E/AndroidRuntime(987): at java.lang.reflect.Method.invoke(Method.java:521)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-30 15:10:53.371: E/AndroidRuntime(987): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-30 15:10:53.371: E/AndroidRuntime(987): at dalvik.system.NativeStart.main(Native Method)
06-30 15:10:56.881: W/webcore(987): Can't get the viewWidth after the first layout
06-30 15:10:58.751: I/Process(987): Sending signal. PID: 987 SIG: 9
誰かが私にこれで何が間違っているのか教えてもらえますか?