Failed to allocate a 1850507580 byte allocation with 1048480 free bytes and 382MB until OOM

Asked

Viewed 434 times

0

I’m putting a 728k image in an Imageview and when I run the app in android studio gives this stick in the application:

java.lang.Outofmemoryerror: Failed to allocate a 1850507580 byte allocation with 1048480 free bytes and 382MB until OOM

Does anyone know why?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.gustavo.easypasse.LoginActivity"
tools:showIn="@layout/activity_login">

<LinearLayout
    android:layout_width="368dp"
    android:layout_height="150dp"
    android:layout_marginTop="50dp"
    android:orientation="horizontal"
    app:layout_constraintTop_toTopOf="parent"
    tools:layout_editor_absoluteX="8dp"
    android:id="@+id/linearLayout">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="150dp"
        android:layout_weight="1"
        app:srcCompat="@drawable/logo_easy_passe_b" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="0dp"
    android:layout_height="50dp"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="30dp"
    android:layout_weight="1"
    android:orientation="horizontal"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout"
    app:layout_constraintHorizontal_bias="0.0">

    <EditText
        android:id="@+id/edtCPF"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:hint="CPF"
        android:inputType="textPersonName" />

</LinearLayout>

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="50dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="8dp"
    android:layout_weight="1"
    android:orientation="horizontal"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp"
    android:id="@+id/linearLayout3">

    <EditText
        android:id="@+id/edtSenha"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:hint="Senha"
        android:inputType="textPersonName" />
</LinearLayout>

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="50dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="41dp"
    android:orientation="horizontal"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp"
    android:id="@+id/linearLayout4">

    <Button
        android:id="@+id/btnAcesse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Acesse" />
</LinearLayout>

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="50dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="7dp"
    android:orientation="horizontal"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout4">

    <Button
        android:id="@+id/btnCadastro"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Cadastro" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

inserir a descrição da imagem aqui

  • 1

    Without seeing your code becomes difficult. But surely he is trying to put in memory something much larger than 728kB. That hence gives 1.72 GB.

  • Your device lacked memory.

  • Want to see xml @Victorstafusa?

  • Gustavo, the best way to take the test to know if this image is the problem is to remove it and see where it goes

  • I put the code in the post, you can look.

  • 1

    @Jeffersonquesado, I’ve removed the image a few times and whenever I take it, the app works great!! It will be the problem because the image is . svg and then converted to . jpg or . png?

  • I just took a look at the details of the image... It has Dimensions 12974 3962, that will be the problem?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.