本文介绍了加入SherlockActionBar后java.lang.OutOfMemoryError出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加SherlockActionBar(布局,因为$ P $光伏版本没有改变),测试我的应用程序在多个设备和一切工作正常,但ACRA已报告关于新和新类似的错误:

I added SherlockActionBar (layouts were not changed since prev version), tested my app in several devices and everything worked fine but ACRA has been reporting about new and new similar errors:

java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aviascanner.aviascanner/net.aviascanner.aviascanner.ui.activities.SearchResultsActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3371)
        at android.app.ActivityThread.access$700(ActivityThread.java:127)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4441)
        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:823)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
        at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255)
        at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
        at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
        at net.aviascanner.aviascanner.ui.activities.SearchResultsActivity.onCreate(SearchResultsActivity.java:105)
        at android.app.Activity.performCreate(Activity.java:4465)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
        ... 12 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:586)
        ... 25 more
Caused by: java.lang.OutOfMemoryError
        at android.graphics.Bitmap.nativeCreate(Native Method)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
        at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
        at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:530)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:505)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:357)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:777)
        at android.content.res.Resources.loadDrawable(Resources.java:1940)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
        at android.view.View.<init>(View.java:2844)
        at android.view.ViewGroup.<init>(ViewGroup.java:418)
        at android.widget.LinearLayout.<init>(LinearLayout.java:178)
        at android.widget.LinearLayout.<init>(LinearLayout.java:174)
        ... 28 more
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255)
        at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
        at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
        at net.aviascanner.aviascanner.ui.activities.SearchResultsActivity.onCreate(SearchResultsActivity.java:105)
        at android.app.Activity.performCreate(Activity.java:4465)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3371)
        at android.app.ActivityThread.access$700(ActivityThread.java:127)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4441)
        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:823)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
        at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:586)
        ... 25 more
Caused by: java.lang.OutOfMemoryError
        at android.graphics.Bitmap.nativeCreate(Native Method)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
        at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
        at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:530)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:505)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:357)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:777)
        at android.content.res.Resources.loadDrawable(Resources.java:1940)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
        at android.view.View.<init>(View.java:2844)
        at android.view.ViewGroup.<init>(ViewGroup.java:418)
        at android.widget.LinearLayout.<init>(LinearLayout.java:178)
        at android.widget.LinearLayout.<init>(LinearLayout.java:174)
        ... 28 more
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:586)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255)
        at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
        at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
        at net.aviascanner.aviascanner.ui.activities.SearchResultsActivity.onCreate(SearchResultsActivity.java:105)
        at android.app.Activity.performCreate(Activity.java:4465)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3371)
        at android.app.ActivityThread.access$700(ActivityThread.java:127)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4441)
        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:823)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
        at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.OutOfMemoryError
        at android.graphics.Bitmap.nativeCreate(Native Method)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
        at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
        at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:530)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:505)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:357)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:777)
        at android.content.res.Resources.loadDrawable(Resources.java:1940)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
        at android.view.View.<init>(View.java:2844)
        at android.view.ViewGroup.<init>(ViewGroup.java:418)
        at android.widget.LinearLayout.<init>(LinearLayout.java:178)
        at android.widget.LinearLayout.<init>(LinearLayout.java:174)
        ... 28 more
java.lang.OutOfMemoryError
        at android.graphics.Bitmap.nativeCreate(Native Method)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
        at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
        at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
        at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:530)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:505)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:357)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:777)
        at android.content.res.Resources.loadDrawable(Resources.java:1940)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
        at android.view.View.<init>(View.java:2844)
        at android.view.ViewGroup.<init>(ViewGroup.java:418)
        at android.widget.LinearLayout.<init>(LinearLayout.java:178)
        at android.widget.LinearLayout.<init>(LinearLayout.java:174)
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:586)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255)
        at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:119)
        at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
        at net.aviascanner.aviascanner.ui.activities.SearchResultsActivity.onCreate(SearchResultsActivity.java:105)
        at android.app.Activity.performCreate(Activity.java:4465)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3371)
        at android.app.ActivityThread.access$700(ActivityThread.java:127)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1162)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4441)
        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:823)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
        at dalvik.system.NativeStart.main(Native Method)

你有任何想法如何解决这一问题?

Do you have any idea how to fix this?

推荐答案

该OutOfMemory例外来,因为在res文件夹中可用的可绘制的。该可绘制应在AA绘制的文件夹可不能在一个文件夹中,以避免OutOfMemoryException异常。

The OutofMemory Exception comes because of the drawables available in the res folders. The drawables should be available in aa the folders of drawable not in a single folder to avoid the OutofmemoryException.

这篇关于加入SherlockActionBar后java.lang.OutOfMemoryError出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 19:39