title: Android Studio app crashes on real device, but works on emulator
body: <p>I started using Android Studio a few weeks ago. I've worked on an app with a normal login screen and on the emulator everything works fine. But if I try to run the app on my Samsung Galaxy S7 Edge (Android 7.0) the app crashes instantly.</p>
  
  <p>I've emulated an Nexus 5 with API 23, when I try it with an emulated Pixel with API 24 the emulator also crashes. So I guess the problem depends on the Android version? </p>
  
  <p><strong>Logcat</strong> (I tinified all images I am using, now this is my new Logcat):</p>
  
  <pre><code>03-30 15:53:13.841 31645-31645/de.mm.uchron E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: de.mm.uchron, PID: 31645
                                                                        java.lang.OutOfMemoryError: Failed to allocate a 3686412 byte allocation with 2474312 free bytes and 2MB until OOM
                                                                            at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                            at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                                                            at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:700)
                                                                            at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:535)
                                                                            at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1179)
                                                                            at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:770)
                                                                            at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:621)
                                                                            at android.content.res.Resources.loadDrawable(Resources.java:1727)
                                                                            at android.content.res.TypedArray.getDrawable(TypedArray.java:945)
                                                                            at android.widget.ImageView.&lt;init&gt;(ImageView.java:157)
                                                                            at android.widget.ImageButton.&lt;init&gt;(ImageButton.java:85)
                                                                            at android.widget.ImageButton.&lt;init&gt;(ImageButton.java:81)
                                                                            at android.support.v7.widget.AppCompatImageButton.&lt;init&gt;(AppCompatImageButton.java:60)
                                                                            at android.support.v7.widget.AppCompatImageButton.&lt;init&gt;(AppCompatImageButton.java:56)
                                                                            at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:118)
                                                                            at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1029)
                                                                            at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087)
                                                                            at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
                                                                            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
                                                                            at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                            at de.mm.uchron.LoginActivity.onCreate(LoginActivity.java:32)
                                                                            at android.app.Activity.performCreate(Activity.java:6912)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
                                                                            at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:154)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:6688)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
  03-30 15:53:20.016 31645-31656/de.mm.uchron I/art: Clamp target GC heap from 261MB to 256MB
  </code></pre>
  
  <p>I've also tried it with my another real device (Samsung GT-I9300 with Android 5.1.1, API 22). The MainActivity loads, but without the background image and if I try to login, the app crashes.</p>
  
  <p>My SDK Tools have all the newest version</p>
  
  <pre><code>Android Emulator: 26.0.0
  Android SDK Platform-Tools: 25.0.4
  Android SDK Tools: 26.0.0
  Google Play services, rev 39: 39.0.0
  Google USB Driver, rev 11: 11.0.0
  Google Web driver: 2
  Intel x86 Emulator Accelerator (HAXM installer): 6.0.5
  </code></pre>
  
  <p>xml file for the MainActivity (LoginActivity):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;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:padding="16dp"
      android:background="@drawable/loginbg"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:id="@+id/rect"
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"&gt;
  
  
      &lt;/LinearLayout&gt;
  
      &lt;android.support.design.widget.TextInputLayout
          android:id="@+id/signup_input_layout_name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="300dp"
          android:layout_marginLeft="30dp"&gt;
  
  
      &lt;EditText
          android:id="@+id/etUsername"
          android:layout_width="222dp"
          android:layout_height="wrap_content"
          android:ems="10"
          android:textColor="#000"
          android:fontFamily="Montserrat"
          android:textSize="16dp"
          android:hint="BENUTZERNAME" /&gt;
      &lt;/android.support.design.widget.TextInputLayout&gt;
  
  
      &lt;android.support.design.widget.TextInputLayout
          android:id="@+id/signup_input_layout_pass"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="30dp"
          android:layout_below="@id/signup_input_layout_name"&gt;
  
          &lt;EditText
              android:id="@+id/etPassword"
              android:layout_width="223dp"
              android:layout_height="wrap_content"
              android:ems="10"
              android:fontFamily="Montserrat"
              android:hint="PASSWORT"
              android:inputType="textPassword"
              android:textColor="#000"
              android:textSize="16dp" /&gt;
      &lt;/android.support.design.widget.TextInputLayout&gt;
  
      &lt;ImageButton
          android:id="@+id/bSignIn"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:layout_alignParentBottom="true"
          android:background="@null"
          android:layout_marginBottom="60dp"
          android:layout_marginLeft="260dp"
          android:fontFamily="Montserrat"
          android:scaleType="fitXY"
          android:src="@drawable/loginbutton"
          android:text="Login" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:text="NEUER ACCOUNT"
          android:id="@+id/tvRegisterLink"
          android:textSize="12sp"
          android:textColor="#B2B2B2"
          android:fontFamily="Montserrat"
          android:layout_alignParentBottom="true"
          android:layout_marginBottom="20dp"
          android:layout_alignStart="@+id/signup_input_layout_pass" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Like I said I am new to Android Studio and I become exasperated with this problem.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>Solved</strong>: Resizing the images solved the problem. I used the suggestions from <a href="https://stackoverflow.com/questions/13024272/android-background-image-size-in-pixel-which-support-all-devices">this link</a> to reduce the resolution of my background files. Now everything works like a charm!</p>