添加SherlockActionBar后会出现java.lang.OutOfMemoryError

时间:2013-03-13 19:09:53

标签: android actionbarsherlock

我添加了SherlockActionBar(布局自上一版本以来没有更改),在多个设备上测试了我的应用程序,一切正常,但ACRA一直在报告新的和新的类似错误:

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)

My question in SherlockActionBar issues tracker

你知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

OutofMemory异常是因为res文件夹中可用的drawable。 drawables应该在drawable文件夹中不在单个文件夹中,以避免OutofmemoryException。