0

06-07 15:02:07.048: E/dalvikvm-heap(1657): 9007416-byte external allocation too large for this process. 06-07 15:02:07.098: E/GraphicsJNI(1657): VM won't let us allocate 9007416 bytes

Screenshot

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|left|right"
android:background="@drawable/bg"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/top_red_bar"
    android:layout_alignParentLeft="true"
    android:paddingLeft="0dp"
    android:scaleType="centerCrop" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="45dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignTop="@+id/imageView1"
    android:layout_centerHorizontal="true"
   
    android:src="@drawable/job_bar" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="238dp"
    android:layout_height="50dp"
    android:layout_below="@+id/imageView1"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_marginTop="123dp"
    android:src="@drawable/button" 
    android:alpha="0.85"
    android:onClick="myhandler"/>

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView3"
    android:layout_marginTop="24dp"
    android:src="@drawable/button" 
    android:alpha="0.85"/>

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="35dp"
    android:layout_height="45dp"
    android:layout_above="@+id/imageView4"
    android:layout_alignLeft="@+id/imageView3"
    android:layout_marginLeft="21dp"
    android:src="@drawable/employer" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/imageView5"
    android:layout_alignTop="@+id/imageView4"
    android:src="@drawable/jobseekers" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView5"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="18dp"
    android:layout_toRightOf="@+id/imageView6"
    android:text="Employer"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#ffffff"
    android:textStyle="bold" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignTop="@+id/imageView4"
    android:text="Job Seekers"
    
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#ffffff"
    android:textStyle="bold" />


</RelativeLayout>

My app gets crashed with error statement Binary XML file <line 20>: Error inflating class <Unknown>. Why does this happen?? Could anyone fix this? And interestingly, when I remove all code except background, it works!!!

Community
  • 1
  • 1
Nikesh Devaki
  • 2,091
  • 2
  • 16
  • 24
  • post the who error not just part of it – Rod_Algonquin Jun 07 '14 at 09:19
  • post error logcat of 10 to 20 lines, that normally is the red portion of lines in logcat – Hamad Jun 07 '14 at 09:26
  • @Hamad These two lines of error displayed in log cat: 06-07 15:02:07.048: E/dalvikvm-heap(1657): 9007416-byte external allocation too large for this process. 06-07 15:02:07.098: E/GraphicsJNI(1657): VM won't let us allocate 9007416 bytes – Nikesh Devaki Jun 07 '14 at 09:34
  • @user2750644 Are you testing on emulator? – Giru Bhai Jun 07 '14 at 09:38
  • yes i'm testing on emulator – Nikesh Devaki Jun 07 '14 at 09:41
  • What is line 20 in xml file? Is the drawable 9MB? – greenapps Jun 07 '14 at 09:43
  • Guys, Now i installed it on my device, its working good. Problem was that, emulator does not supporting large memory. Fixed!!! Thank you so much for your help. – Nikesh Devaki Jun 07 '14 at 09:51
  • @user2750644 As I suggest in answer. – Giru Bhai Jun 07 '14 at 09:51
  • 1
    Please, keeep in mind that older devices may have a limited memory. Consider using a smaller image for your background. After all, being stretched, it will give the same **blur effect**. – Phantômaxx Jun 07 '14 at 10:02
  • 1
    @user2750644 : **"Problem was that, emulator does not supporting large memory. Fixed!!!"** : Don't be so sure of that. As Der Golem points out, different devices and Android versions will have limited amounts of memory to handle things like images. Just because it works on your device doesn't mean it will work on *all* devices. – Squonk Jun 07 '14 at 10:18
  • Squonk is right. You should try to make your app work on the largest possible amount of devices. And the emulator is really handy to show you **design or code flaws**. – Phantômaxx Jun 07 '14 at 12:53

1 Answers1

0

Check your @drawable parts i.e the size of images you using for this layout - the VM runs out of memory when decoding the bitmap. Make the image dimensions smaller.

Edit

As I see from your logcat
You are leaking resources (most likely the Drawable object). For more info see at tools in What Android tools and methods work best to find memory/resource leaks?

Community
  • 1
  • 1
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74