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 trialFrankie Lamar
11,120 PointsR reference errors with 2nd activity
I'm working on the Blog Reader app in Android Studio. When I create the second activity for the web view all of my references to R generate errors. When I delete the activity all the reference s to R are fine in the remaining activity. Whats going on here? Would creating a new activity effect R references?
3 Answers
Gloria Dwomoh
13,116 PointsMaybe the thing you are referencing with R does not exist. I am not sure if you are doing... R.string or R.id, but make sure your resource exists and that you have imported R.
Luis Carlos Rúa Sánchez
Courses Plus Student 1,754 PointsHi Frankie, creating a new activity doesn't affect the R class. Maybe when you reference it in the second activity the import is from android.R, not from your own activity so see what the import is, it should be your package name. R.
Otherwise please post your code, in this way is to hard to help
Frankie Lamar
11,120 PointsI reference R.id and R.sting in the first activity and it works fine in that activity. When I create 2nd activity references to R.anything in both activities throw an error that says "R cannot be resolved to a value". Must be a bug in android studio then.