E/AndroidRuntime: FATAL EXCEPTION: main

+1 Hamzah Quraishi · February 6, 2016
I application won't open in my android phone, someone help????

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;
import android.widget.RelativeLayout;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {

RelativeLayout hamzahLayout = new RelativeLayout(this);
Button redButton = new Button(this);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();

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;

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);

Post a Reply


Oldest  Newest  Rating
0 Gary Whitney · February 7, 2016
Posting your code would require someone to load it in their system, and that is not likely to happen.
It is better to post the Stack Trace.
It is best to learn to understand the Stack Trace.

1. The top of the trace is where the error occurs.
2. Somewhere below you will see a call by YOUR code.
It will even tell you the line on which the error occurred.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator