0

i am working on my one applciation in which i have 9 tabs with tabhost and activitygroup

with 9 tabs my applcation works perfectly but when i added 10 th tab for language screen i have 7 lanuages in dropdown on changing of dropdown values application language is changed but after that when i navigating screens 4 to 5 times

Out of memory exception occurs here is error exception

Exception

07-04 13:41:57.941: E/AndroidRuntime(4866): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at com.milagemaster.Activity_setup.onCreate(Activity_setup.java:51)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
07-04 13:41:57.941: E/AndroidRuntime(4866):     ... 31 more
07-04 13:41:57.941: E/AndroidRuntime(4866): Caused by: java.lang.reflect.InvocationTargetException
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.widget.RelativeLayout.<init>(RelativeLayout.java:171)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at java.lang.reflect.Constructor.constructNative(Native Method)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.LayoutInflater.createView(LayoutInflater.java:500)
07-04 13:41:57.941: E/AndroidRuntime(4866):     ... 39 more
07-04 13:41:57.941: E/AndroidRuntime(4866): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:447)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.content.res.Resources.loadDrawable(Resources.java:1705)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at android.view.View.<init>(View.java:1850)
07-04 13:41:57.941: E/AndroidRuntime(4866):     at 

Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/relroot"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:gravity="top" >

    <LinearLayout
        android:id="@+id/lnrTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical" >

        <com.milagemaster.utility.Header
            android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="50dp" />

        <RelativeLayout
            android:id="@+id/relativeHome"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/title" >

            <TextView
                android:id="@+id/txtAddData"
                style="@style/TitleTextAppearance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:text="@string/results"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="@color/black" />

            <Button
                android:id="@+id/btnEmail"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:text="Send Mail"
                android:visibility="visible" />
        </RelativeLayout>
    </LinearLayout>

    <FrameLayout
        android:id="@+id/lnrscroll_barsMain"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/lnrTitle"
        android:layout_centerHorizontal="true" >

        <ImageView
            android:id="@+id/imgShadow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/shadow_title" />
    </FrameLayout>

    <ScrollView
        android:id="@+id/scroll_barsMain"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/lnrTitle"
        android:layout_marginBottom="10dp"
        android:fadingEdge="none"
        android:scrollbars="vertical" >

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <RelativeLayout
                android:id="@+id/relativeResult"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_gravity="top" >

                <LinearLayout
                    android:id="@+id/relativetitle"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/top_blue" >

                    <TextView
                        android:id="@+id/txtResultTitle"
                        android:layout_width="80dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="10dp"
                        android:ellipsize="end"
                        android:gravity="center_horizontal"
                        android:text="@string/vehcile"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="@color/black"
                        android:textSize="16dp" />

                    <Spinner
                        android:id="@+id/spnSelectVehicle"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_marginRight="5dp"
                        android:background="@drawable/dropdown"
                        android:paddingLeft="10dp" />
                </LinearLayout>
                <!--
                     <TextView
                    android:id="@+id/txtResultTitle"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/top_blue"
                    android:gravity="center_vertical|center_horizontal"
                    android:text="your vehicle"
                    android:textColor="@color/black"
                    android:textSize="18dp" />


                -->

                <LinearLayout
                    android:id="@+id/frameresult"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/relativetitle"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:background="@drawable/bg_box"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/txtResult"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="10dp"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text=""
                        android:textColor="@color/black"
                        android:textSize="14dp" />

                    <TextView
                        android:id="@+id/txtDate"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="15dp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="10dp"
                        android:gravity="center_vertical|center_horizontal"
                        android:text="(mpg/kpl)"
                        android:textColor="@color/mileage1"
                        android:textSize="14dp"
                        android:textStyle="bold" />

                    <LinearLayout
                        android:id="@+id/linearLayout1"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="10dp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="10dp"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/txtAvg"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center_vertical|center_horizontal"
                            android:text=""
                            android:textColor="@color/mileage1"
                            android:textSize="22sp"
                            android:textStyle="bold"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/txtAddFirstTime"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center_vertical|center_horizontal"
                            android:text=""
                            android:textColor="@color/gray_text"
                            android:textSize="12dp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/lnrLifeTime"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="10dp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="10dp"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/txtResultLifeTime"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:gravity="center"
                            android:text=""
                            android:textColor="@color/black"
                            android:textSize="14dp"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/txtLifeMileage"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="15dp"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:gravity="center_vertical|center_horizontal"
                            android:text="(mpg/kpl)"
                            android:textColor="@color/mileage1"
                            android:textSize="14dp"
                            android:textStyle="bold"
                            android:visibility="gone" />
                    </LinearLayout>
                </LinearLayout>

                <Button
                    android:id="@+id/btnSave"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/frameresult"
                    android:layout_centerHorizontal="true"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginTop="15dp"
                    android:background="@drawable/themed_btnlarge"
                    android:text="@string/savelocationasfavorite"
                    android:textSize="16sp" />

                <LinearLayout
                    android:id="@+id/frameButton"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/btnSave"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginTop="15dp" android:gravity="center_vertical">

                    <Button
                        android:id="@+id/btnChartMilage"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/themed_mileagechart"
                        android:text="@string/mileagechart"
                        android:textSize="14dp" />

                    <Button
                        android:id="@+id/btnCostGallons"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/themed_fuelcost"
                        android:text="Cost/unit Chart"
                        android:textSize="14dp" />

                    <Button
                        android:id="@+id/btnChartFuel"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/themed_fualpricechart"
                        android:text="@string/fuelchart"
                        android:textSize="14dp" />
                </LinearLayout>

                <Button
                    android:id="@+id/btnShare"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/frameButton"
                    android:layout_centerHorizontal="true"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_marginTop="15dp"
                    android:background="@drawable/themed_btnlarge"
                    android:text="@string/share"
                    android:textSize="16sp" />
            </RelativeLayout>
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

Please give me some suggestion

bindal
  • 1,940
  • 1
  • 20
  • 29

4 Answers4

0

This OOME exception is occurring because of bitmaps.

Are you calling bitmap.recycle() method after using bitmap? You should always call this method as it will free up the resources held by the bitmap.

This error occurs because of memory leak in your code. You need to find it. You can use MAT (plugin) for eclipse software to find the memory leak.

For detailed info, please see my answer on the same.

If this doesn't solve the problem, please let me know, we'll find some other solution.

Thank you :)

Community
  • 1
  • 1
Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61
0

First look into this exception Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown> you have an error in one of your layout .XML

Aqif Hamid
  • 3,511
  • 4
  • 25
  • 38
0

I doubt it is recreating of the activity. If you watch carefully when you change your language, The current activity died and Android re-create a new Activity with new Language. It is similar to changing screen orientation, so it will be ok if you manage your memory usage. Make sure you don't have memory leak, by doing the following. There is a youtube video

  • make sure your activity is thread safe
  • when first activity died, check if the resource are dealloc properly
NyanLH
  • 480
  • 1
  • 6
  • 17
  • I have used tabhost with activitygroup is there problem with that? – bindal Jul 04 '12 at 06:27
  • Try to conserve memory usage and prevent memory leak. you can try to transfer your heavy object via onsaveinstancestate(). – NyanLH Jul 04 '12 at 06:32
0

You may be using large bitmaps as backgrounds. The Out of memory exception occurs during layout inflation. Use smaller bitmaps if possible.

Shashika
  • 1,151
  • 1
  • 9
  • 21