every time i tried to create a simple app , and using Button to jump to another activity its shows me "unfortunately app name has stopped"
once i delete the button code and keep everything as same as it is .
the app run perfectly , and when press the button show "unfortunately app name has stopped"
 package com.example.OWA.tesst;
 import android.content.Intent;
 import android.support.v7.app.ActionBarActivity;
 import android.os.Bundle;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.Button;
 public class MainActivity extends ActionBarActivity {
 Button N = (Button)findViewById(R.id.B1);
 protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);  }
public void direct(View v){
    Intent I = new Intent(this,sec.class);
    startActivity(I);
}
}
layout code
   <Button
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Click"
   android:id="@+id/B1"
   android:onClick="direct"
   android:layout_centerVertical="true"
   android:layout_centerHorizontal="true" />
 
     
     
    