2

I am completely lost with this one. My app works perfectly on API 2.1 on my handset and through the emulator. I have just run it through a 2.2 emulator and I am getting a crash and this error:

 04-27 20:29:41.293: ERROR/AndroidRuntime(341): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebp/com.ebp.ebpMainMenu}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.os.Looper.loop(Looper.java:123)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.main(ActivityThread.java:4363)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at java.lang.reflect.Method.invoke(Method.java:521)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at dalvik.system.NativeStart.main(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.Activity.setContentView(Activity.java:1622)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at com.ebp.ebpMainMenu.onCreate(ebpMainMenu.java:58)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     ... 11 more
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.reflect.InvocationTargetException
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.widget.LinearLayout.<init>(LinearLayout.java:92)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at java.lang.reflect.Constructor.constructNative(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     ... 21 more
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.nativeCreate(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.content.res.Resources.loadDrawable(Resources.java:1705)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.View.<init>(View.java:1850)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.View.<init>(View.java:1799)
04-27 20:29:41.293: ERROR/AndroidRuntime(341):     at android.view.ViewGroup.<init>(ViewGroup.java:284)

In the main.xml file, here is line #2

<LinearLayout 
       android:id="@+id/linearLayout3" 
       android:background="@drawable/mainbackground"
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical">

and here is main line 58:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
}

1 Answer 1

2

Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget may be the real culprit here. Try using smaller image to see if it is a memory-related issue.

Check out these links for examples of similar issues: java.lang.OutOfMemoryError: bitmap size exceeds VM budget - android - how many images?
OutOfMemory exception when loading bitmap from external storage

Sign up to request clarification or add additional context in comments.

5 Comments

My biggest drawable is 44k and I've just strimmed down main.xml so it only uses 4 different layouts - am stumped!
Doh it was the background image, the resolution was too high
The same happened to me and after zillions of ways to resize bitmaps, I found out it was a background image!!!
@sandalone and how did you fix that ? did you move the background image somewhere else ?
@Thomas It was really long time ago and I cannot remember. Either I had a large image in /drawable folder which I moved to XHDPI folder or I implemented image-resample logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.