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 a Simple Android App (2014) Basic Android Programming Accessing Views in Code

Erik Russell
Erik Russell
1,032 Points

Cannot locate R file

So far the lesson is going great. I am having one issue however, I cannot locate the R file as I have an updated version of Android Studio. The build folder is missing along with all other files and folders inside of it.

Could somebody please advise on where to locate the R file. Thanks.

6 Answers

Ah, right - sorry I was on the wrong track.

The files are still there, but the newer versions of Android Studio organise them differently than in that video.

On the top, left above your files listing, there is a drop-down that is probably set to show the Android robot icon with the word Android next to it. Click the drop down and change it to Project and you'll get the full path from app such as app/build/generated/res/rs/ etc.

Switch to Packages, and the R files is shown under the android.support package, if you're using that.

Hope that makes sense now!

Steve.

Erik Russell
Erik Russell
1,032 Points

Thanks again Steve! Can't wait to get home from work and get back to learning.

That is auto-generated. Try a "Invalidate Caches and Restart" - that usually fixes stuff like that.

If that doesn't work do let me know and we can think again!

Steve.

Are you getting "R cannot be resolved into a variable"?

I'm doing a bit of digging - a screenshot of you error would help, possibly.

Steve.

Have you tried cleaning and then building the project?

There are some useful pointers in this Stack Overflow post.

Your solution is likely to be in there somewhere.

The R.java is created by the compiler; you never (as far as I'm aware) change any code in it. We reference it when accessing application resources, menus and layouts.

If you've got this auto-generated stuff missing, which is odd, try a rebuild, or a make or a clean - try it all!

Erik Russell
Erik Russell
1,032 Points

I think either you are misunderstanding me or I am completely lost (more likely the latter) but there is a "build" folder shown in the video. I do not have said folder. Inside of that directory is the r file a ways down.

Having the Same Problem,

Try doing this tutorial with the latest android studio, the whole directory structure is different so things are harder to find or are not there anymore.

Yeah, Android Studio moves on quickly. Hopefully the answer marked as 'Best Answer' above should help. If not, please shout back.

Steve.