Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build an Interactive Story App Intents and Multiple Activities Getting Resources from the Context

[SOLVED]When i try to find to type key_name it says it dont exists.

Hi, When we try assign the key_name i get an error which says it dont exists but i declare this variable in the string.xml file.. : String key = resources.getString(R.string.key_name)

this is the picture of the mainActivity: https://gyazo.com/e85680e54014899b1aa77ec4cac18ee8

strings.xml file: https://gyazo.com/cb87c84dadda3f4a2c4788f549239620

I dont understand why i cant get a refernce of it, when i type R.string if i type dot i get the refernce of app_name...

Lauren Moineau Tonnie Fanadez

SOLVED: I just need to restart android stuido and it worked, its strange.

Hi noob developer. I'm glad you sorted it out. The scary red R is quite common I'm afraid. There are a few solutions (after making sure the problem is not in your resource file):

  • Build > Rebuild Project
  • File > Sync Project with Gradle
  • File > Invalidate Caches / Restart
  • Restart (as you did)

Hope that helps :)