Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Testing and Debugging Making a Toast

Uros Dukic
Uros Dukic
1,001 Points

Code challenge Toast problem

Can somebody help me with this challenge. I wrote the code: Toast toast = Toast makeText(this, "All done!", Toast.LENGTH_LONG);

And in preview I can find 6 errors...

Tnx

4 Answers

Stone Preston
Stone Preston
42,016 Points

you named your toast variable wrong and you forgot the . between Toast and makeText.

you were supposed to use the variable that was there at the start of the challenge. when you start the challenge it looks like this:

Toast allDoneToast;

so then you just add the assignment to that, be sure and include the . between Toast and makeText

Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);

once you fix those two small issues you should be able to move on to the next task of the challenge

Stone Preston
Stone Preston
42,016 Points

did you leave the code from the first two tasks in place? I tried using your code and passed just fine:

code for task 3:

Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
allDoneToast.show();

Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
Uros Dukic
Uros Dukic
1,001 Points

I did it and still have one error.

JavaTester.java:31: allDoneToast is already defined in run() Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);

Stone Preston
Stone Preston
42,016 Points

post the code you have in your challenge. your code needs to look like this:

Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);

if you have something similar to whats below thats not correct. only declare it once.

//this is not correct. you have the same variable declared twice
Toast allDoneToast; 
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Uros Dukic
Uros Dukic
1,001 Points

In 3rd task I did it next way and preview show mi this error... Sorry guys if I am annoying but I really want to learn this...

Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show(); ^ Tnx.