Application Crash when using android.widget.Button class as a global variable
<p>I can't for the life of me figure this out, and I've searched as thoroughly as I can.</p>

<p>I've got a block of code like so:</p>

<pre><code>    public class TwoPlayerGame extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);                    
}



public GameStuff game = new GameStuff();
public Player playerOne = new Player();
public Player playerTwo = new Player();

public Player[] players = {playerOne, playerTwo};

public Button cardOne=(Button)findViewById(R.id.card1);
public Button cardTwo=(Button)findViewById(R.id.card2);
public Button cardThree=(Button)findViewById(R.id.card3);
public Button cardFour=(Button)findViewById(R.id.card4);
public Button cardFive=(Button)findViewById(R.id.card5);

public Button[] buttons={cardOne, cardTwo, cardThree, cardFour, cardFive};

@Override
public void onStart(){
    super.onStart();


    for(int i=0; i&lt;=1; i++){
        dealCards(players[i]);
    }



    for (int i = 0; i&lt;=4; i++){
        buttons[i].setText(playerOne.cardsInHand[i]);
    }


}


}
</code></pre>

<p>As written this will crash as soon as the Activity starts (it'll even crash if I change the onStart override into a new method altogether). If I move all the Button declarations into the onStart method, everything works fine, but then they won't be global. If I move them into onCreate, they won't be global, according to Eclipse, and I get errors that won't let me compile. </p>

<p>All the other global variables work fine where they are, and I need the buttons to be global so I don't have to keep re-declaring them in new methods. </p>

<p>Am I overlooking something blindingly obvious (probably)? And what is it?</p>
