Make a point the every time this code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Comes before all your code in the MainActivity class
it met also cause you some problems.
Try it.