Android Studio OutOfMemoryError
Android Studio OutOfMemoryError
我制作了一个应用程序,并一直在 Android Studio 上使用不同的屏幕尺寸 (AVD) 对其进行测试。我从小的开始,然后逐步提高。它非常慢,但我得到了 5.96" 屏幕并且一切正常。在 5.96" 上尝试时我收到以下错误:
01-01 11:59:09.226 1317-1317/com.luanca.charangomaster E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 29833456 byte allocation with 4194304 free bytes and 12MB until OOM"
01-01 11:59:09.228 1317-1317/com.luanca.charangomaster D/skia﹕ --- allocation failed for scaled bitmap
01-01 11:59:09.232 1317-1317/com.luanca.charangomaster D/AndroidRuntime﹕ Shutting down VM
--------- beginning of crash
01-01 11:59:09.246 1317-1317/com.luanca.charangomaster E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.luanca.charangomaster, PID: 1317
android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29833456 byte allocation with 4194304 free bytes and 12MB 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.drawable.Drawable.createFromResourceStream(Drawable.java:973)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2423)
at android.content.res.Resources.loadDrawable(Resources.java:2330)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3730)
at android.view.ViewGroup.<init>(ViewGroup.java:491)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:248)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:244)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:240)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
现在我很困惑,因为该应用程序适用于所有其他屏幕尺寸。任何人对如何解决这个问题有一些了解?是代码错误还是我必须在 Android Studio 中修复的问题?
也适用于 7" 和 10" 屏幕。我不明白 5.96" 的错误...
这就是它发生的地方。当我按下前 2 个按钮之一时(应该打开一个对话框,同时仍然在同一个 activity 上(作为链接,因为我达到了 Whosebug 的限制):
https://dl.dropboxusercontent.com/u/43384650/activity_main.xml
还有 2 个对话框:
可拉木
我希望它是一个形象而且只是
将一些颜色代码替换到这一行 n try
android:background="@drawable/wood"
作为
android:background="#000000"
我希望它对你有用。
我 运行 遇到了同样的问题,并通过将 AVD 的 VM 堆大小从 64 MB 增加到 128 MB 来解决它。
我制作了一个应用程序,并一直在 Android Studio 上使用不同的屏幕尺寸 (AVD) 对其进行测试。我从小的开始,然后逐步提高。它非常慢,但我得到了 5.96" 屏幕并且一切正常。在 5.96" 上尝试时我收到以下错误:
01-01 11:59:09.226 1317-1317/com.luanca.charangomaster E/art﹕ Throwing OutOfMemoryError "Failed to allocate a 29833456 byte allocation with 4194304 free bytes and 12MB until OOM"
01-01 11:59:09.228 1317-1317/com.luanca.charangomaster D/skia﹕ --- allocation failed for scaled bitmap
01-01 11:59:09.232 1317-1317/com.luanca.charangomaster D/AndroidRuntime﹕ Shutting down VM
--------- beginning of crash
01-01 11:59:09.246 1317-1317/com.luanca.charangomaster E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.luanca.charangomaster, PID: 1317
android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29833456 byte allocation with 4194304 free bytes and 12MB 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.drawable.Drawable.createFromResourceStream(Drawable.java:973)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2423)
at android.content.res.Resources.loadDrawable(Resources.java:2330)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3730)
at android.view.ViewGroup.<init>(ViewGroup.java:491)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:248)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:244)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:240)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
at android.app.Dialog.setContentView(Dialog.java:490)
at com.luanca.charangomaster.CustomDialog.<init>(CustomDialog.java:25)
at com.luanca.charangomaster.ChordActivity.onClick(ChordActivity.java:178)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
现在我很困惑,因为该应用程序适用于所有其他屏幕尺寸。任何人对如何解决这个问题有一些了解?是代码错误还是我必须在 Android Studio 中修复的问题?
也适用于 7" 和 10" 屏幕。我不明白 5.96" 的错误...
这就是它发生的地方。当我按下前 2 个按钮之一时(应该打开一个对话框,同时仍然在同一个 activity 上(作为链接,因为我达到了 Whosebug 的限制):
https://dl.dropboxusercontent.com/u/43384650/activity_main.xml
还有 2 个对话框:
可拉木
我希望它是一个形象而且只是 将一些颜色代码替换到这一行 n try
android:background="@drawable/wood"
作为
android:background="#000000"
我希望它对你有用。
我 运行 遇到了同样的问题,并通过将 AVD 的 VM 堆大小从 64 MB 增加到 128 MB 来解决它。