java.lang.OutOfMemoryError 背景
java.lang.OutOfMemoryError background
这是一个,
java.lang.RuntimeException: Unable to start activity ComponentInfo{ders.raydingoz.com.dersprogram/ders.raydingoz.com.dersprogram.aksamyemek}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access0(ActivityThread.java:161)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
at android.app.Activity.setContentView(Activity.java:2015)
at ders.raydingoz.com.dersprogram.aksamyemek.onCreate(aksamyemek.java:38)
at android.app.Activity.performCreate(Activity.java:5431)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 23 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
at android.content.res.Resources.loadDrawable(Resources.java:3056)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3694)
at android.view.View.<init>(View.java:3624)
at android.view.ViewGroup.<init>(ViewGroup.java:474)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:236)
... 26 more
还有一个;
java.lang.OutOfMemoryError: Failed to allocate a 111384 byte allocation with 24040 free bytes and 23KB until OOM
at java.nio.charset.Charsets.toUtf8Bytes(Native Method)
at java.lang.String.getBytes(String.java:775)
at java.lang.String.getBytes(String.java:759)
at com.android.webview.chromium.WebViewChromium.loadDataWithBaseURL(WebViewChromium.java:664)
at android.webkit.WebView.loadDataWithBaseURL(WebView.java:940)
at com.google.android.gms.ads.internal.s.g.loadDataWithBaseURL(SourceFile:328)
at com.google.android.gms.ads.internal.o.m.run(SourceFile:57)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
我从 google 游戏、应用 运行 自己 phone 和其他人那里顺利获得了这份报告。但 S4 和 S5 设备有报告。背景图片已经100KB。调试没有显示任何问题。我想我需要减少使用的内存。不是吗?
这是"What to avoid when writing a question on Whosebug"的一个很好的例子。
如果您正在开发应用程序,并且需要分配大内存堆,则需要在清单中添加标签应用程序下:
android:largeHeap="true"
这是一个,
java.lang.RuntimeException: Unable to start activity ComponentInfo{ders.raydingoz.com.dersprogram/ders.raydingoz.com.dersprogram.aksamyemek}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access0(ActivityThread.java:161)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:626)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
at android.app.Activity.setContentView(Activity.java:2015)
at ders.raydingoz.com.dersprogram.aksamyemek.onCreate(aksamyemek.java:38)
at android.app.Activity.performCreate(Activity.java:5431)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
... 23 more
Caused by: java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
at android.content.res.Resources.loadDrawable(Resources.java:3056)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3694)
at android.view.View.<init>(View.java:3624)
at android.view.ViewGroup.<init>(ViewGroup.java:474)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:236)
... 26 more
还有一个;
java.lang.OutOfMemoryError: Failed to allocate a 111384 byte allocation with 24040 free bytes and 23KB until OOM
at java.nio.charset.Charsets.toUtf8Bytes(Native Method)
at java.lang.String.getBytes(String.java:775)
at java.lang.String.getBytes(String.java:759)
at com.android.webview.chromium.WebViewChromium.loadDataWithBaseURL(WebViewChromium.java:664)
at android.webkit.WebView.loadDataWithBaseURL(WebView.java:940)
at com.google.android.gms.ads.internal.s.g.loadDataWithBaseURL(SourceFile:328)
at com.google.android.gms.ads.internal.o.m.run(SourceFile:57)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5834)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
我从 google 游戏、应用 运行 自己 phone 和其他人那里顺利获得了这份报告。但 S4 和 S5 设备有报告。背景图片已经100KB。调试没有显示任何问题。我想我需要减少使用的内存。不是吗?
这是"What to avoid when writing a question on Whosebug"的一个很好的例子。
如果您正在开发应用程序,并且需要分配大内存堆,则需要在清单中添加标签应用程序下:
android:largeHeap="true"