RxDev
RxDev

Reputation: 295

Java,Lang.OutOfMemoryError on Xamarin android deployment

Hello I am currently having this message whenever I try to deploy my app to the emulator and it happened exactly where I attach a layout to an activity i-e

SetContentView(Resource.Layout.Main);

The complete error message says " Failed to allocate a 6569942 byte allocation with 1048576 free bytes and 95 until OOM.

here is my layout :

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="@+id/coordLayout"
    tools:context=".MainActivity">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
            <ImageView
                android:layout_marginTop="40sp"
                android:id="@+id/logo"
                android:layout_width="200sp"
                android:layout_height="200sp"
                android:src="@drawable/cpdep"
                android:layout_gravity="center_horizontal" />
            <EditText
                android:id="@+id/user"
                android:layout_marginTop="20sp"
                android:layout_gravity="center_horizontal"
                android:layout_width="300sp"
                android:layout_height="wrap_content"
                android:hint="Username" />
            <EditText
                android:id="@+id/pass"
                android:layout_gravity="center_horizontal"
                android:layout_width="300sp"
                android:layout_height="wrap_content"
                android:hint="Password"
                android:layout_marginTop="20sp" />
            <Button
                android:layout_marginTop="20sp"
                android:layout_marginRight="40sp"
                android:id="@+id/myButton"
                android:layout_width="100sp"
                android:layout_height="wrap_content"
                android:text="Log in"
                android:layout_gravity="right" />
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

Do you have any idea on how to solve this? thanks in advance for your help

Upvotes: 0

Views: 69

Answers (1)

RxDev
RxDev

Reputation: 295

I figure out what went wrong , it was because of the size of the image I use in my layout. it was 2.89 MB with a resolution of 6200x6199. I resize it with photoshop and everything is working properly thanks to @apenide

Upvotes: 1

Related Questions