Error: incorrect_toast cannot be resolved


Hi, I have an error once I created the Toast event listeners in the onCreate() method. it says:[quote] incorrect_toast cannot be resolved or is not a field[/quote].

Yet I checked in my strings.xml file and I have made strings for both of these variables there:

<string name="correct_toast">Correct!</string> <string name="incorrect_toast">Incorrect!</string>

Here is my file (most of it):


import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class QuizActivity extends Activity {

private Button mTrueButton;
private Button mFalseButton;

protected void onCreate(Bundle savedInstanceState) {
    mTrueButton = (Button)findViewById(;
    mTrueButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Toast.makeText(QuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show();
    mFalseButton = (Button)findViewById(;
    mFalseButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show();

The errors are on 2 lines, where you see [quote]R.string.incorrect_toast[/quote] and [quote]R.string.correct_toast[/quote].

Why are these errors here? Can’t figure it out.



Hi Nonimizu
I also had this issue yesterday and could not see a typo. In the end I found that the auto-generated file had not generated the lines for the two toast items. I closed the windows and open them again and it appeared to refresh and add the lines to the file. I am not in front of the code to be able to be more precise, but hope my explanation gives you some ideas. It seemed like there was a delay in update the file via Eclipse.

  • Max.


Thanks Max! The more I use Eclipse, the more I see many software errors happen here and there. So good call. I think this error went away mysteriously, so probably like you described it! Sometimes saving or closing/reopening does some good. :unamused: