Unfortunately, GeoQuiz has stopped


I can’t get GeoQuiz to run and get the following error dump. I have tried the books solutions and they work.

I am up to lisitng 2.7 wiring up textview

The problem sems to lie with the following code as when I compile with it commented out the app will run (although it doesn’t display the question)

	//int question = mQuestionBank[mCurrentIndex].getQuestion();
package com.bignerdranch.android.geoquiz;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class QuizActivity extends Activity {
	private Button mTrueButton;
	private Button mFalseButton;
	private Button mNextButton;
	private TextView mQuestionTextView;
	private TrueFalse[] mQuestionBank = new TrueFalse [] {
			new TrueFalse(R.string.question_oceans, true),
			new TrueFalse(R.string.question_mideast,false),
			new TrueFalse(R.string.question_africa,false),
			new TrueFalse(R.string.question_america,true),
			new TrueFalse(R.string.question_asia,true)
	private int mCurrentIndex = 0;

	protected void onCreate(Bundle savedInstanceState) {
		// Wiring up the TextView
		mQuestionTextView = (TextView)findViewById(R.id.question_text_view);
		int question = mQuestionBank[mCurrentIndex].getQuestion();
		//get references to view objects
		mTrueButton = (Button)findViewById(R.id.true_button);
		mFalseButton = (Button)findViewById(R.id.false_button);
		// set listener
		mTrueButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Toast.makeText(QuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show();
		mFalseButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show();

	public boolean onCreateOptionsMenu(Menu menu) {

		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.quiz, 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();
		if (id == R.id.action_settings) {
			return true;
		return super.onOptionsItemSelected(item);

<?xml version="1.0" encoding="utf-8"?>

    <string name="app_name">GeoQuiz</string>
    <string name="action_settings">Settings</string>
	<string name="true_button">True</string>
	<string name="false_button">False</string>
	<string name="correct_toast">Correct!</string>
	<string name="incorrect_toast">Incorrect!</string>
	<string name="next_button">Next</string>
	<string name="question_oceans">The Pacific Ocean is larger than the Atlantic Ocean.</string>
	<string name="question_mideast">The Suez Canal conects the Red Sea and the Indian Ocean.</string>
	<string name="question_africa">The source of the Nile is in Egypt.</string>
	<string name="question_america">The Amazon River is the longest river in the Americas.</string>
	<string name="question_asia">Lake Baikal is the world\'s oldest a freshwater lake.</string>

I am using ADT 22.6.2.


Have fixed this issue by:

Reinstalling ADT.

Creating a new project.

Copying over books source code for the main files.

Removing fragment file

[quote=“Nijjwal”][quote=“samsidx”]Hi all, I found many beginners troubling with new ADT, so I would like to tell some changes so that it will look exactly the same as book…

  1. Let wizard generate the fragment_quiz.xml and all that stuff.
  2. Now go to res/layout and delete fragment_quiz.xml and activity_quiz.xml
  3. Right click on res/layout and add android xml file and name it activity_quiz.xml and make its root view LinearLayout, now you have layout look like book
  4. Go to src/QuizActivity.java and delete all the code after setContentView(R.layout.activity_quiz)
  5. Validate the syntax. You are done. :wink:[/quote]

Thanks samsidx, your method worked like a charm. :smiley:[/quote]

From the menu doing : Project -> Clean

Then it runs :wink: