1

I published an app on android playstore , lot of people tried it with no problems but on android cellphone (Galaxy note III) the app froze and i got this message on my developer console in android account.

 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.cade.codigos/org.cade.codigos.ui.activities.RequestDataForm}: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.RelativeLayout
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2294)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2348)
 at android.app.ActivityThread.access700ドル(ActivityThread.java:159)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:137)
 at android.app.ActivityThread.main(ActivityThread.java:5414)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:525)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.widget.RelativeLayout
 at android.view.LayoutInflater.createView(LayoutInflater.java:626)
 at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
 at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
 at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
 at android.app.Activity.setContentView(Activity.java:1956)
 at org.cade.codigos.ui.activities.RequestDataForm.onCreate(Unknown Source)
 at android.app.Activity.performCreate(Activity.java:5369)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
 ... 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:600)
 ... 25 more
Caused by: java.lang.OutOfMemoryError
 at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
 at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
 at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
 at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
 at android.content.res.Resources.loadDrawable(Resources.java:2988)
 at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
 at android.view.View.<init>(View.java:3563)
 at android.view.View.<init>(View.java:3492)
 at android.view.ViewGroup.<init>(ViewGroup.java:469)
 at android.widget.RelativeLayout.<init>(RelativeLayout.java:242)
 ... 28 more

This is my layout

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/ScrollView01"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:fillViewport="true"
 android:scrollbars="none" >
<LinearLayout android:layout_width="match_parent"
 android:layout_height="match_parent">
<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:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 android:paddingBottom="@dimen/activity_vertical_margin"
 tools:context="org.cade.codigos.ui.activities.RequestDataForm"
 android:background="@drawable/background">
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="NOMBRE*"
 android:id="@+id/lblNombre"
 android:layout_marginTop="80dp"
 android:layout_alignParentTop="true"
 android:layout_alignParentRight="true"
 android:textSize="15dp"
 android:textColor="#e7f5fe"
 android:layout_marginBottom="5dp"
 android:layout_alignParentLeft="true"
 android:layout_marginLeft="10dp" />
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtNombre"
 android:hint="@string/hint_nombre"
 android:layout_below="@+id/lblNombre"
 android:layout_alignParentRight="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="APELLIDO*"
 android:id="@+id/lblApellido"
 android:layout_below="@+id/txtNombre"
 android:layout_alignParentRight="true"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtApellido"
 android:hint="@string/hint_apellido"
 android:layout_below="@+id/lblApellido"
 android:layout_alignParentRight="true" />
 <Button
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:text="ENVIAR"
 android:textColor="#e7f5fe"
 android:id="@+id/btnEnviar"
 android:background="@drawable/button_form"
 android:minHeight="41dp"
 android:layout_below="@+id/txtCelularRecomendar2"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="10dp" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="MAIL*"
 android:id="@+id/lblMail"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtEmpresa"
 android:layout_alignRight="@+id/txtEmpresa"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />/>
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textEmailAddress"
 android:ems="10"
 android:id="@+id/txtMail"
 android:hint="@string/hint_mail"
 android:layout_below="@+id/lblMail"
 android:layout_alignRight="@+id/lblMensajeRecomendar" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="CELULAR*"
 android:id="@+id/lblCelular"
 android:layout_below="@+id/txtMail"
 android:layout_alignParentLeft="true"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp"
 />
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textEmailAddress"
 android:ems="10"
 android:id="@+id/txtCelular"
 android:hint="@string/hint_celular_recomendar"
 android:layout_below="@+id/lblCelular"
 android:layout_alignParentLeft="true" />
 <ImageView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/imageView"
 android:layout_alignParentTop="true"
 android:layout_centerHorizontal="true"
 android:background="@drawable/logo" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="PROFESIÓN*"
 android:id="@+id/lblProfesion"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtApellido"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />/>
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtProfesion"
 android:hint="@string/hint_profesion"
 android:layout_below="@+id/lblProfesion"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="EMPRESA"
 android:id="@+id/lblEmpresa"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtProfesion"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />/>
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtEmpresa"
 android:hint="@string/hint_empresa"
 android:layout_below="@+id/lblEmpresa"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="NÚMERO DE CLIENTE"
 android:id="@+id/lblNumeroCliente"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtCelular"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />/>
 <EditText
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:inputType="textEmailAddress"
 android:ems="10"
 android:id="@+id/txtNumeroCliente"
 android:hint="@string/hint_numero_cliente"
 android:layout_below="@+id/lblNumeroCliente"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="RECOMIENDE AMIGOS PARA REGALARLE LA APLICACIÓN &quot;CADE-CODIGOS&quot; Y PARTICIPE DEL SORTEO DE UN &quot;CURSO-CADE&quot; A SU ELECCIÓN(TENDRÁ UNA CHANCE POR CADA AMIGO RECOMENDADO)"
 android:id="@+id/lblMensajeRecomendar"
 android:textSize="15dp"
 android:textColor="#e7f5fe"
 android:layout_below="@+id/txtNumeroCliente"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginTop="3dp"
 android:layout_marginLeft="1dp" />
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtMailRecomendar1"
 android:hint="@string/hint_email_recomendar"
 android:layout_below="@+id/lblMailRecomendar1"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="MAIL "
 android:id="@+id/lblMailRecomendar1"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtApellidoRecomendar1"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp"/>
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="CELULAR"
 android:id="@+id/lblCelularRecomendar1"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtMailRecomendar1"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp" />
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtCelularRecomendar1"
 android:hint="@string/hint_celular_recomendar"
 android:layout_below="@+id/lblCelularRecomendar1"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="NOMBRE"
 android:id="@+id/lblNombreRecomendar1"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/lblAmigo1"
 android:layout_alignParentRight="true"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp" />
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtNombreRecomendar1"
 android:hint="@string/hint_nombre"
 android:layout_below="@+id/lblNombreRecomendar1"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="APELLIDO"
 android:id="@+id/lblApellidoRecomendar1"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtNombreRecomendar1"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"
 android:layout_marginTop="3dp"/>
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtApellidoRecomendar1"
 android:hint="@string/hint_apellido"
 android:layout_below="@+id/lblApellidoRecomendar1"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="AMIGO 1"
 android:id="@+id/lblAmigo1"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/lblMensajeRecomendar"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="5dp" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="AMIGO 2"
 android:id="@+id/lblAmigo2"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtCelularRecomendar1"
 android:layout_alignRight="@+id/lblMensajeRecomendar"
 android:layout_marginTop="5dp" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="NOMBRE"
 android:id="@+id/lblNombreRecomendar2"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/lblAmigo2"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"/>
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtNombreRecomendar2"
 android:hint="@string/hint_nombre"
 android:layout_below="@+id/lblNombreRecomendar2"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="APELLIDO"
 android:id="@+id/lblApellidoRecomendar2"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtNombreRecomendar2"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"/>
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtApellidoRecomendar2"
 android:hint="@string/hint_apellido"
 android:layout_below="@+id/lblApellidoRecomendar2"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="MAIL "
 android:id="@+id/lblMailRecomendar2"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtApellidoRecomendar2"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"/>
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtMailRecomendar2"
 android:hint="@string/hint_email_recomendar"
 android:layout_below="@+id/lblMailRecomendar2"
 android:layout_alignParentLeft="true" />
 <TextView
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textAppearance="?android:attr/textAppearanceMedium"
 android:text="CELULAR"
 android:id="@+id/lblCelularRecomendar2"
 android:textSize="15dp"
 android:textColor="#E6E6E6"
 android:layout_below="@+id/txtMailRecomendar2"
 android:layout_alignParentLeft="true"
 android:layout_marginTop="5dp"
 android:layout_marginBottom="5dp"
 android:layout_marginLeft="10dp"/>
 <EditText
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:inputType="textPersonName"
 android:ems="10"
 android:id="@+id/txtCelularRecomendar2"
 android:hint="@string/hint_celular_recomendar"
 android:layout_below="@+id/lblCelularRecomendar2"
 android:layout_alignParentLeft="true"
 android:layout_marginBottom="10dp" />
</RelativeLayout>
</LinearLayout>
 </ScrollView>
asked Sep 28, 2015 at 17:09
1
  • 1
    It looks like in this activity exist a lot of large images, or something like this. Also GC may not collected previous images or object and it also may cause out of memory Commented Sep 28, 2015 at 17:13

3 Answers 3

3

What is the cause?

The mains reason could be that you have one or more memory leaks in your application, or that you are simply trying to allocate too much memory in this layout. It could be on this layout with the number/size of images you are trying to display, or it could be on a previous layout that is still holding a reference to bitmaps that are taking up memory. This will occur on any device, but the Samsung Galaxy III has less memory than newer phones, which may be a reason it occurs so often on this phone.

How to find solution?

There is only one way to detect your problem.

  1. Open activity that cause application crash, and at this moment make memory dump.

  2. Open another activity, and crate memory dump here.

  3. Analyse memory dump and try to find memory leaks.

  4. Only you can understand where memory leaks can be (it can be a large image, or you use a lot of static objects, may be has not closed stream yet, etc), and memory dump would help you in this trip.

Remember, only you can solve this problem, and when you solve it you would never make the same mistakes again!!

Good Luck!

See also

  1. Investigating Your RAM Usage.
  2. Memory Analysis for Android Applications.

P.S.

I Have just analysed your error stack and found that OutOfMemory cause your drawable, that has been loaded from resources, if it is an image, you can make less resolution for it, and maybe problem would be gone.

Caused by: java.lang.OutOfMemoryError
 at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
 at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
 at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
 at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
 at android.content.res.Resources.loadDrawable(Resources.java:2988)
 at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 

I hope, this topic would help you!

P.S.S.

It is looks like that your logo image take a lot of memory( it is to large - high resolution), it can cause your problem, take a memory dump and analyse how many bytes it has been taken

yiati
1,0231 gold badge15 silver badges28 bronze badges
answered Sep 28, 2015 at 17:34
Sign up to request clarification or add additional context in comments.

Comments

1

I can see that in your RelativeLayout you are using a custom background the @drawable/background. If this resource (PNG, JPG or 9 Patch Drawable) is not properly optimized in order to support multiple screens and devices then this can cause you OutOfMemory exceptions on devices with low amount of RAM where the HEAP is too small to handle that amount of pixels. Please make sure you optimized that resource accordingly:

http://developer.android.com/guide/practices/screens_support.html

answered Sep 28, 2015 at 18:02

2 Comments

the resolution of background is 1920*1558 , which seems to be pretty big, but the size of the image is 124kb which doesnt seem to be so much, does it depend on the resolution or on the size?
No, you are wrong, because in memory it would be about 1920*1558*3*8. where 1920*1558 - it is total count of pixels, 3 - count of channels (RGB), 8 - bite per pixel (depends on your configurations). And don`t forget about png compression that does not apply for memory.
1

As @Cosmin said, your problem seem to be 'out of memory' caused by Loading Bitmap with no treatment(load large images).

A lot of people face this problem, my recomendation is: read this

After that, you will know how to works with bitmaps in android.

answered Sep 28, 2015 at 17:27

1 Comment

Good luck, and if is possible and you think my answer is correct, can you vote ? Thank you.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.