0

First off let me apologize for any layout/formatting errors, I'm doing this on my cell.

That being said, I cannot for the life of me figure out what is wrong with the below xml. With it in my layout file, the app crashes on load, but if I cut it out, the app loads and runs fine. Any help in figuring out the problem would be greatly appreciated.

Note: The drawables are all .jpg files in the drawable folder. Note: This section is cut from within another vertical linearlayout

Not sure if can/how to copy logcat from Aide. However, the logcat finally popped and it is an out of memory exception. I will try reducing the image size and come back.

<TextView
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:layout_width="wrap_content"
    android:text="Current Favorites"/>

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:gravity="center">

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:orientation="vertical"
        android:gravity="center">

        <ImageView
            android:layout_height="100dp"
            android:layout_width="wrap_content"
            android:src="@drawable/mia_sollis"/>

        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Mia Sollis"/>

    </LinearLayout>

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:orientation="vertical"
        android:gravity="center">

        <ImageView
            android:layout_height="100dp"
            android:layout_width="wrap_content"
            android:src="@drawable/pepper_kester"/>

        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Pepper Kester"/>

    </LinearLayout>

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:orientation="vertical"
        android:gravity="center">

        <ImageView
            android:layout_height="100dp"
            android:layout_width="wrap_content"
            android:src="@drawable/jayme"/>

        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Jayme Langford"/>

    </LinearLayout>

</LinearLayout>

3 Answers3

2

The possible answer is,

<ImageView
            android:layout_height="100dp"
            android:layout_width="wrap_content"
            android:src="@drawable/mia_sollis"/>

image "mia_sollis" is too big and hence is giving out of memory error. Try out with smaller size image, it will solve your problem.

Tushar
  • 128
  • 5
1

Possible reasons based on your XML layout:

1) You forgot to add this on top of your layout file

xmlns:android="http://schemas.android.com/apk/res/android"

2) Second and the most important

You have multiple root tag, TextView and LinearLayout both of them is your root. However, you MUST have one root layout and inside it, do what ever you want.

Cheers!

O_o
  • 1,103
  • 11
  • 36
  • As stated in OP, this xml snippet is cut from a larger xml. The header tag is in the full xml, and the root tag is a relativelayout, withing that is a vertical linearlayout, within that is where I tried this. I can edit OP to make that clearer if need be, sorry for bad formatting lol – DEF Software Solutions Sep 29 '16 at 12:14
  • Please add the full layout @DEFSoftwareSolutions. Otherwise, it's hard to determine. Sorry for not being helpful :/ – O_o Sep 29 '16 at 12:17
0

You have to post your Log

I guess

maybe the size of images is too big for your app memory.

add this to your Application tag in Manifest

<application
        .......
        android:largeHeap="true"
        ........ >
AITAALI_ABDERRAHMANE
  • 2,499
  • 1
  • 26
  • 31