this is my first time in android studios and also anything related to coding since I took java in college. I'm currently following an easy youtube tutorial on how to make a simple app. Unfortunately whenever I run the AVD i get the "unfortunately your app has stopped" error. I have no idea what the problem is and I've been searching the internet and can't find an answer. I know its simple and you guys can probably find it quickly, so thats why I'm here. Thanks to whoever helps!
This is my main activity:
package com.example.owner.pickupline;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Heres my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cleanImage"
android:layout_centerVertical="true"
android:src="@drawable/clean"
android:nestedScrollingEnabled="false"
android:cropToPadding="false"
android:scaleType="fitXY"
android:longClickable="false" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Clean"
android:id="@+id/cleanButton"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textSize="50dp"
android:textColor="#ffffff"
android:background="#a4000000"
android:longClickable="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/dirtyImage"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:nestedScrollingEnabled="false"
android:src="@drawable/dirty"
android:scaleType="fitXY"
android:longClickable="true" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Dirty"
android:id="@+id/dirtyButton"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textSize="50dp"
android:textColor="#ffffff"
android:background="#a4000000" />
</RelativeLayout>
</LinearLayout>
Heres some of the error message
FATAL EXCEPTION: main
11-12 19:42:34.563 2376-2376/com.example.owner.pickupline E/AndroidRuntime: Process: com.example.owner.pickupline, PID: 2376
java.lang.OutOfMemoryError: Failed to allocate a 144000012 byte allocation with 1048576 free bytes and 63MB until OOM
11-12 19:42:34.563 2376-2376/com.example.owner.pickupline E/AndroidRuntime: at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
11-12 19:42:34.563 2376-2376/com.example.owner.pickupline E/AndroidRuntime: at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-12 19:42:34.563 2376-2376/com.example.owner.pickupline E/AndroidRuntime: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
11-12 19:42:34.563 2376-2376/com.example.owner.pickupline E/AndroidRuntime: at