问题描述
我正在创建一个关于交通标志的应用程序。交通标志为.png格式。他们中的一些我正在水平展示。但是当尝试打开活动时,我从android市场错误报告中得到这个错误。这是我的错误报告: < java.lang.RuntimeException:无法启动活动ComponentInfo {com.besalti.svenskavagmarken / com.besalti.svenskavagmarken.varningsmarken}:android.view.InflateException:二进制XML文件行#645:错误膨胀类<未知>
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
在android.app.ActivityThread.access $ 1500(ActivityThread.java:121)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:943)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:130)
在android.app.ActivityThread.main(ActivityThread.java:3701)
在java.lang.reflect.Method.invokeNative (Native Method)
在java.lang.reflect.Method.invoke(Method.java:507)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
在dalvik.system.NativeStart.main(本机方法)
导致:android.view。 InflateException:二进制XML文件行#645:膨胀类< unknown>
在android.view.LayoutInflater.createView(LayoutInflater.java:518)
在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
在android .view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:626 )
在android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
在android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
在android.view.LayoutInflater。 rInflate(LayoutInflater.java:626)
在android.view.LayoutInflater.inflate(LayoutInflater.java:408)
在android.view.LayoutInflater.inflate(LayoutInflater.java:320)
在android.view.LayoutInflater.inflate(LayoutInflater.java:276)
在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:227)
在android.app.Activity .setContentView(Activity.java:1657)
在com.besalti.svenskavagmarke n.varningsmarken.onCreate(varningsmarken.java:25)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
... 11更多
导致:java.lang.reflect.InvocationTargetException
java.lang.reflect.Constructor.constructNative(Native Method)
在java.lang。 reflect.Constructor.newInstance(Constructor.java:415)
在android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 26更多
引起的:java.lang .OutOfMemoryError:位图大小超过VM预算
在android.graphics.BitmapFactory.nativeDecodeAsset(本机方法)
在android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:494)
在android。 graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
在android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
在android.content.res.Resources.loadDrawable(资源。 java:1720)
在和roid.content.res.TypedArray.getDrawable(TypedArray.java:601)
在android.widget.ImageView。< init>(ImageView.java:122)
在android.widget.ImageView。< ; init>(ImageView.java:112)
... 29 more>
任何人都可以帮我吗?
位图大小超过VM预算错误实际上是在本机图形库(Skia)中。这是一个令人困惑的问题,因为问题真的是Skia在本地堆中的位图数据的内存已经用完了。请参阅的背景。
为了弄清楚这一点,您必须仔细查看位图使用情况。
- 确保不会留下位图参考浮动
- 在空闲时执行循环/ null onn位图(这似乎有助于)。
Hi i am creating an app about traffic signs. traffic signs are in .png format. some of them I am showing in horizontalscrollview. But when try to open activities , I get this error from android market error reports. here is my error report:
<java.lang.RuntimeException: Unable to start activity ComponentInfo{com.besalti.svenskavagmarken/com.besalti.svenskavagmarken.varningsmarken}: android.view.InflateException: Binary XML file line #645: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
at android.app.ActivityThread.access$1500(ActivityThread.java:121)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #645: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:227)
at android.app.Activity.setContentView(Activity.java:1657)
at com.besalti.svenskavagmarken.varningsmarken.onCreate(varningsmarken.java:25)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 26 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:494)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
at android.content.res.Resources.loadDrawable(Resources.java:1720)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.ImageView.<init>(ImageView.java:122)
at android.widget.ImageView.<init>(ImageView.java:112)
... 29 more>
can anyone help me?
The "bitmap size exceeds VM budget" error is actually in the native graphics library (Skia). It is a tad confusing as the problem is really that Skia has run out of memory in the native heap for bitmap data. See BitmapFactory OOM driving me nuts for background.To get round this, you will have to look carefully at your bitmap usage
- making sure that you do not leave bitmap references floating
- doing a recycle / null onn bitmaps as they become free (this appears to help).
这篇关于java.lang.OutOfMemoryError BitmapFactory.nativeDecodeAsset()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!