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

bot .net
bot .net
9,766 Points

[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:

strings.xml file:

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.

Lauren Moineau
Lauren Moineau
Pro Student 8,364 Points

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 :)