title: Android Studio Activity keeps Crashing
body: <p>Background: my activities are connected to each other through buttons (imagebuttons and buttons). they should launch a new activity every time they are clicked.</p>
  
  <p>But my app keeps crashing after every 3 or so clicks. a message saying "Unfortunately THEAPP5 has topped". it will then relaunch that specific page at which point the button on that page will start working and connect to the next activity. however to only then repeat the issue on a different activity.</p>
  
  <p>I have checked the button names/types/ID's etc. just can't figure out why this is happening. <strong>I'm a beginner with Android Studio.</strong></p>
  
  <p>I have attached the complete code from one activity. all activities have the same basic code. </p>
  
  <pre><code>package com.example.d.myluxuryapp5;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.Window;
  import android.widget.ImageButton;
  
  public class AutoLux extends Activity
  {
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
  
      requestWindowFeature(Window.FEATURE_NO_TITLE);
  
      setContentView(R.layout.activity_auto_lux);
  
      ImageButton AutoLuxury = (ImageButton) findViewById(R.id.luxuryUserBtn);
  
      AutoLuxury.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              Intent intent = new Intent(v.getContext(), LuxMM.class);
              startActivity(intent);
          }
      });
  }}
  </code></pre>
  
  <hr>
  
  <pre><code>&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:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:background="@drawable/luxury_background"
  tools:context="com.example.d.myluxuryapp5.AutoLux"&gt;
  
  
  &lt;ImageButton
      android:layout_width="200dp"
      android:layout_height="200dp"
      android:id="@+id/luxuryUserBtn"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="100dp"
      android:background="@drawable/luxury_user_button"
      /&gt;
  
  &lt;ImageButton
      android:layout_width="300dp"
      android:layout_height="50dp"
      android:id="@+id/otherUserBtn"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:background="@drawable/other_user_button"
      /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Thanks for your help </p>
  
  <h2>LOGCAT for the moment the app crashes + relaunches</h2>
  
  <pre><code>    03-07 10:43:34.081 3818-3818/com.example.d.myluxuryapp5 E/AndroidRuntime:FATAL EXCEPTION: main
      Process: com.example.d.myluxuryapp5, PID: 3818
      java.lang.RuntimeException: Unable to start activity     ComponentInfo{com.example.d.myluxuryapp5/com.example.d.myluxuryapp5.OptOne}: android.view.InflateException: Binary XML file line #43: Binary XML file line #43: Error inflating class &lt;unknown&gt;
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
      at android.app.ActivityThread.-wrap11(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   Caused by: android.view.InflateException: Binary XML file line #43: Binary XML file line #43: Error inflating class &lt;unknown&gt;
      at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
      at android.app.Activity.setContentView(Activity.java:2166)
      at com.example.d.myluxuryapp5.OptOne.onCreate(OptOne.java:23)
      at android.app.Activity.performCreate(Activity.java:6237)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
   Caused by: android.view.InflateException: Binary XML file line #43: Error inflating class &lt;unknown&gt;
      at android.view.LayoutInflater.createView(LayoutInflater.java:645)
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
      at android.app.Activity.setContentView(Activity.java:2166) 
      at com.example.d.myluxuryapp5.OptOne.onCreate(OptOne.java:23) 
      at android.app.Activity.performCreate(Activity.java:6237) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
   Caused by: java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Constructor.newInstance(Native Method)
      at android.view.LayoutInflater.createView(LayoutInflater.java:619)
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
      at android.app.Activity.setContentView(Activity.java:2166) 
      at com.example.d.myluxuryapp5.OptOne.onCreate(OptOne.java:23) 
      at android.app.Activity.performCreate(Activity.java:6237) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
   Caused by: java.lang.OutOfMemoryError: Failed to allocate a 1172244 byte allocation with 197464 free bytes and 192KB until OOM
      at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
      at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
      at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
      at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
      at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
      at android.content.res.Resources.loadDrawableForCookie(Resources.java:2635)
      at android.content.res.Resources.loadDrawable(Resources.java:2540)
      at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
      at android.view.View.&lt;init&gt;(View.java:3948)
      at android.widget.TextView.&lt;init&gt;(TextView.java:677)
      at android.widget.TextView.&lt;init&gt;(TextView.java:671)
      at android.widget.TextView.&lt;init&gt;(TextView.java:667)
      at java.lang.reflect.Constructor.newInstance(Native Method) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
      at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
      at android.app.Activity.setContentView(Activity.java:2166) 
      at com.example.d.myluxuryapp5.OptOne.onCreate(OptOne.java:23) 
      at android.app.Activity.performCreate(Activity.java:6237) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
      at android.app.ActivityThread.-wrap11(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>