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

glenn romaniuk
glenn romaniuk
32,520 Points

Android studio - cannot resolve symbol

Today all the @strings in my androidmanifest.xml are showing up in red. Example: android:label="@string/title_activity_edit_friends". Says it cannot resolve symbol. My strings.xml exists. I can't use the @string/ reference from anywhere. I tried to sync project with gradle. Did not fix. Any ideas?

13 Answers

Have you tried to rebuild and clean project?

glenn romaniuk
glenn romaniuk
32,520 Points

i clicked rebuild and clean. All @strings still display in red. I also clicked the invalidate crashes/restart. Didn't fix it. I also clicked sync cradle. Didn't fix it. I'm a .net developer. Compared to Visual Studio I find android studio unstable. Whats your experience? Any more ideas?

Android Studio always seems to be a little buggy. Look in your R.java and check if the strings are listed in there.

glenn romaniuk
glenn romaniuk
32,520 Points

I moved my project folder from drive C to D a couple of days ago. It worked directly after that so I don't suspect that caused this. Would that have something to do with it?

glenn romaniuk
glenn romaniuk
32,520 Points

Question is there some type of project location(s) setting that needs to be updated if i move the entire project from C to D drive?

Possibly. I moved folders around once and it caused me problems. Luckily I had everything backed up on github so I deleted from my machine and cloned.

glenn romaniuk
glenn romaniuk
32,520 Points

I tested the strings.xml and r.java from a .java file that consumes R.string.hello_world.

  1. new project where R.string.hello_world and @string/ works -when i right click on a R.string.hello_world and click show declaration it take me to strings.xml

  2. in my existing project with the strings.xml problem i'm able to type R.string.hello_world and intellesense works but when i right click on a R.string.hello_world and click show declaration it take me to R.java file.

Something definitely wrong here. Is there a path or something I need to update?

You could try deleting the generated folder then rebuilding and cleaning.

glenn romaniuk
glenn romaniuk
32,520 Points

deleted the debug folder containing the R.java and rebuilt and cleaned still the same problem

glenn romaniuk
glenn romaniuk
32,520 Points

since i moved the project from where it was originally created is there some type of setting or path that is still referencing the old location that needs to be update?

Did you delete "debug" or "generated"?

glenn romaniuk
glenn romaniuk
32,520 Points

Was at the end of my rope and very desperate. I created a new project that worked and then used the file 'import project...' button Made all those problems go away

Sorry dude. I meant the folder called "generated". But you've fixed it now so its all good.

glenn romaniuk
glenn romaniuk
32,520 Points

I'll note that for next time. We should keep in touch as i'm not having any luck connecting with the rest of the droid dev's. Gona be doing some serious droid dev over the next year so i'll likely have to pick someones brain at some point. Thanks for the help.

Definitely. I started my first job as an android dev last September so meeting more people has been a priority.

glenn romaniuk
glenn romaniuk
32,520 Points

I'm a .net ninja with over 20 years experience developing win and web forms apps. Doing allot of dev using .net's continuum and xamarin but the future has me developing more native apps.