10

I have an out if memory error reported by some users on google play that i cant seem to reproduce no matter how hard I try.

The error is shown on the line of my java file where I try to set the layout of my file. Here is the complete dump of logcat:


      {java.lang.RuntimeException: Unable to start activity ComponentInfo{org.djodjo.android.sport.GrassrootsDragRacing/org.djodjo.android.sport.GrassrootsDragRacing.LogSheet}: android.view.InflateException: Binary XML file line #2: Error inflating class 
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
              at android.app.ActivityThread.access$600(ActivityThread.java:128)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4514)
              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:980)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
              at dalvik.system.NativeStart.main(Native Method)
              Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class 
              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:274)
              at android.app.Activity.setContentView(Activity.java:1835)
              at org.djodjo.android.sport.GrassrootsDragRacing.LogSheet.onCreate(LogSheet.java:20)
              at android.app.Activity.performCreate(Activity.java:4470)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
              ... 11 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)
              ... 23 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:618)
              at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
              at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
              at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:775)
              at android.content.res.Resources.loadDrawable(Resources.java:1968)
              at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
              at android.view.View.(View.java:2834)
              at android.view.View.(View.java:2771)
              at android.view.ViewGroup.(ViewGroup.java:379)
              at android.widget.RelativeLayout.(RelativeLayout.java:174)
              ... 26 more

Any help would be highly appreciated :)

EDIT

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/log_sheet_background_new"
    android:orientation="vertical" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="#00FFFFFF"
        android:orientation="horizontal" >

        <!--
             <ImageView  
                android:id = "@+id/topLogo"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:background="@drawable/top_logo3"
                android:layout_alignParentLeft="true"
            />
        -->

        <ImageView
            android:id="@+id/btnHelp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_gravity="right"
            android:layout_marginRight="3dip"
            android:layout_marginTop="3dip"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:src="@drawable/help_up" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="5dip"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/btnNewLogSheet"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dip"
            android:layout_marginLeft="5dip"
            android:layout_marginRight="0dip"
            android:background="@drawable/info_box_p1"
            android:clickable="true"
            android:text="Add New Log"
            android:textColor="#FF000000"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/btnDeleteAll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dip"
            android:layout_marginLeft="3dip"
            android:layout_marginRight="0dip"
            android:background="@drawable/info_box_p1"
            android:clickable="true"
            android:text="Clear All"
            android:textColor="#FF000000"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/btnLogSheetPredictET"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dip"
            android:layout_marginLeft="3dip"
            android:layout_marginRight="0dip"
            android:background="@drawable/info_box_p1"
            android:clickable="true"
            android:text="Predict ET"
            android:textColor="#FF000000"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/btnLogSheetListByDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="5dip"
            android:layout_marginLeft="3dip"
            android:layout_marginRight="0dip"
            android:background="@drawable/info_box_p1"
            android:clickable="true"
            android:text="Search by date"
            android:textColor="#FF000000"
            android:textSize="16sp"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>
8
  • what is size of image your are loading in your layout file? Commented Feb 8, 2013 at 7:28
  • Please share the layout you are trying to inflate Commented Feb 8, 2013 at 7:28
  • can you paste the XML are you rtrying to inflate? thanks. Commented Feb 8, 2013 at 7:28
  • 1
    Check whether there's an image involved which Android tries to scale. As far as my observations go, I believe I've seen problems both with large images (file-size wise) which need to be scaled and large images with smaller file size which needs to be scaled. Commented Feb 8, 2013 at 7:29
  • Could you post the layout.xml file ? Commented Feb 8, 2013 at 7:29

2 Answers 2

8

this error comes when size of images are larger then the either width or height of emulator. so check your images and re-size them.

for more info refer to this linkBinary XML file line #2: Error inflating class android.widget.LinearLayout

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

2 Comments

This is the only logical reason i can also think that could be behind this error but the image is only 800 kb , what happened to "minimum memory that android is going to allocate to one app is 16 MB" thing?
correct me if i am wrong but i think it is more about the size of the image then width and height cause i have tested the app on the smallest mobile i could lay my hands on but it still worked fine and the error was on mobiles of rather higher display resolution.
2

I see this error when the app is running out of memory ie. there is a memory leak somewhere. I have made a image heavy app and only after switching to Googles new Volley framework have the error gone away.

Comments

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.