title: Android application. App works very slow and is causing an error
body: <p>I just recently started an android development class in school and am wondering why my code is not working? Any help would be greatly appreciated. I am creating a Tip Tracker app to help me keep track of my tips when delivering pizzas. I know a similar app was created, but I want to create my own, and it is also my Final Project for the semester. For now I'm just trying to navigate between windows to make sure I can link everything together before going too crazy on the UI. I don't see where I actually have a problem, but I'm getting the error &quot;Unfortunately, [app] has stopped working&quot; when clicking the &quot;Delivery&quot; button on my main screen. So my second window never actually appears. Also, my app is very slow and unresponsive sometimes. Thank you to anyone who can help. My code is as follows:</p>
  <pre><code>&lt;LinearLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;0dip&quot;
      android:layout_weight=&quot;1&quot;
      android:gravity=&quot;center|bottom&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;Button
          android:layout_width=&quot;155dp&quot;
          android:layout_height=&quot;60dp&quot;
          android:layout_gravity=&quot;center_horizontal|center&quot;
          android:layout_marginBottom=&quot;10dp&quot;
          android:background=&quot;@drawable/button_bg&quot;
          android:text=&quot;Delivery&quot;
          android:id=&quot;@+id/deliveryButton&quot; /&gt;
  
      &lt;Button
          android:layout_width=&quot;155dp&quot;
          android:layout_height=&quot;60dp&quot;
          android:layout_gravity=&quot;center_horizontal|center&quot;
          android:layout_marginBottom=&quot;10dp&quot;
          android:background=&quot;@drawable/button_bg&quot;
          android:text=&quot;LOG&quot;
          android:id=&quot;@+id/logButton&quot; /&gt;
  
      &lt;Button
          android:layout_width=&quot;155dp&quot;
          android:layout_height=&quot;60dp&quot;
          android:layout_gravity=&quot;center_horizontal|center&quot;
          android:layout_marginBottom=&quot;10dp&quot;
          android:background=&quot;@drawable/button_bg&quot;
          android:text=&quot;MAPS&quot;
          android:id=&quot;@+id/mapsButton&quot; /&gt;
  </code></pre>
  <p>The code for my main java file is:</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private Button launchDeliveryActivity;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      launchDeliveryActivity = (Button) findViewById(R.id.deliveryButton);
  
      launchDeliveryActivity.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View view)
          {
              launchActivity();
          }
      });
  }
  
  private void launchActivity()
  {
      Intent intent = new Intent(this, orderDetailsActivity.class);
      startActivity(intent);
  }
  </code></pre>
  <p>And my second window is something I quickly threw together to make sure I would be able to navigate from the home screen to the second window and back:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:background=&quot;@drawable/order_details&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;Button
          android:layout_width=&quot;120dp&quot;
          android:layout_height=&quot;60dp&quot;
          android:text=&quot;Home&quot;
          android:id=&quot;@+id/homeScreenButton&quot; /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>And finally, my second java file:</p>
  <pre><code>public class orderDetailsActivity extends AppCompatActivity {
  
  private Button homeScreen;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.order_details);
  
      homeScreen = (Button) findViewById(R.id.homeScreenButton);
  
      homeScreen.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View view)
          {
              finish();
          }
      });
  }
  </code></pre>
  <p>Logs are:</p>
  <p>1:29 AM Executing tasks: [:app:assembleDebug]</p>
  <p>1:29 AM Gradle build finished in 1s 781ms</p>
  <p>1:31 AM Executing tasks: [:app:assembleDebug]</p>
  <p>1:31 AM Gradle build finished in 7s 15ms</p>
  <p>1:31 AM Instant Run performed a full build and install since the installation on the device does not match the local build on disk. (Don't show again)</p>
  <p>1:40 AM Executing tasks: [:app:assembleDebug]</p>
  <p>1:40 AM Gradle build finished in 1s 203ms</p>
  <p>1:43 AM Executing tasks: [:app:assembleDebug]</p>
  <p>1:43 AM Gradle build finished in 983ms</p>
  <p>EDIT:
  The Logcat is:</p>
  <pre><code>03-27 03:37:59.550 31525-31525/com.example.boley.personaldeliveryassistant E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.boley.personaldeliveryassistant, PID: 31525
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.boley.personaldeliveryassistant/com.example.boley.personaldeliveryassistant.orderDetailsActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class &lt;unknown&gt;
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
      at android.app.ActivityThread.access$1100(ActivityThread.java:221)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:158)
      at android.app.ActivityThread.main(ActivityThread.java:7224)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class &lt;unknown&gt;
      at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
      at com.example.boley.personaldeliveryassistant.orderDetailsActivity.onCreate(orderDetailsActivity.java:15)
      at android.app.Activity.performCreate(Activity.java:6876)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
      at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:158) 
      at android.app.ActivityThread.main(ActivityThread.java:7224) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
   Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class &lt;unknown&gt;
      at android.view.LayoutInflater.createView(LayoutInflater.java:657)
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:706)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:774)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
      at com.example.boley.personaldeliveryassistant.orderDetailsActivity.onCreate(orderDetailsActivity.java:15) 
      at android.app.Activity.performCreate(Activity.java:6876) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
      at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:158) 
      at android.app.ActivityThread.main(ActivityThread.java:7224) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
   Caused by: java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Constructor.newInstance(Native Method)
      at android.view.LayoutInflater.createView(LayoutInflater.java:631)
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:706) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:774) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
      at com.example.boley.personaldeliveryassistant.orderDetailsActivity.onCreate(orderDetailsActivity.java:15) 
      at android.app.Activity.performCreate(Activity.java:6876) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
      at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:158) 
      at android.app.ActivityThread.main(ActivityThread.java:7224) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
   Caused by: java.lang.OutOfMemoryError: Failed to allocate a 207355916 byte allocation with 16773008 free bytes and 53MB until OOM
      at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
      at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
      at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856)
      at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675)
      at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:2228)
      at android.content.res.Resources.loadDrawableForCookie(Resources.java:4215)
      at android.content.res.Resources.loadDrawable(Resources.java:4089)
      at android.content.res.Resources.loadDrawable(Resources.java:3939)
      at android.content.res.TypedArray.getDrawable(TypedArray.java:886)
      at android.view.View.&lt;init&gt;(View.java:4230)
      at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:589)
      at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:202)
      at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:198)
      at android.widget.LinearLayout.&lt;init&gt;(LinearLayout.java:194)
      at java.lang.reflect.Constructor.newInstance(Native Method) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:706) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:774) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
      at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
      at com.example.boley.personaldeliveryassistant.orderDetailsActivity.onCreate(orderDetailsActivity.java:15) 
      at android.app.Activity.performCreate(Activity.java:6876) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
      at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:158) 
      at android.app.ActivityThread.main(ActivityThread.java:7224) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)  
  </code></pre>