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 Testing and Debugging Toast Notifications

Problems with Toast show()

Hi! I have problems with this line of code:

  • Toast.makeText(FunFactsActivity.this, "Yey", Toast.LENGTH_SHORT).show();

There are several errors:

  • Cannot resolve symbol makeText
  • Unexpected token
  • Unknown class "LENGTH_SHORT"
  • Missing method body, or declare abstract

I have already imported Toast & Toast LENGTH SHORT and I searched everywhere but I don't have a clue about how to fix this error, thanks!

2 Answers

Hi there,

That's odd as the code looks fine. Have you definitely imported:

import android.widget.Toast;

Does Android Studio try to autocomplete the line for you?

Not sure what else could be wrong - but if it's not understanding what makeText is, then something isn't included correctly, I'm guessing.

Let me know if that's the import you have used?

Steve.

I solve it! This error appears when you make a Toast in the wrong line. The toast should have been create inside the method onCreate. Thanks!

Glad you got it fixed! :+1: