44

I am trying to add a layout to an Android project:

Right clicked on res folder New | Directory. The directory was created however not shown under app/res. Maybe because empty dirs are hidden by default? Went to Windows explorer and added a file to the newly created directory (hidden in Android Studio). Back in the Studio, how can I 'refresh' the project structure to show the newly created directory and the file under it?

Essentially my question is, what is the alternative to Eclipse' Refresh menu option?

kmansoor
  • 4,265
  • 9
  • 52
  • 95
  • 2
    This shouldn't be happening. Have you tried exploring your project via the different options (above your project you have the options for Android, Packages, and Project. One of the other views may give you what you want. – zgc7009 Feb 06 '15 at 21:04
  • @zgc7009 Correct! The 'Structure' view is what I needed. – kmansoor Feb 06 '15 at 21:07

5 Answers5

38

If I find that Android Studio is out of synch with the file system I use File->Synchronize. Or equivalently, Ctrl+Alt+Y or the little circle with arrows menu button.

mx0
  • 6,445
  • 12
  • 49
  • 54
  • 6
    If this doesn't work you can try `File` > `Invalidate Caches and Restart` which will rebuild the project index – Sourabh Feb 18 '16 at 17:49
  • 1
    Also, if you find a way to avoid using the OS's file system and instead add files/directories from within Android Studio, you might reduce the likelihood of needing to do the rather time consuming `Invalidate Caches and Restart` – Dale Jun 17 '17 at 14:52
  • It looks as if this has been renamed 'Reload All From Disk'. – JellicleCat Jul 27 '22 at 18:50
13

In the case of device files - right click on the directory in question in the Device File Explorer and click on 'Synchronize'

MathewLamb
  • 131
  • 1
  • 2
5

There is a view option right on top of the hierarchy folders (see attachment). Select "Packages"

Screenshot of project menu in Android Studio]

Edric
  • 24,639
  • 13
  • 81
  • 91
xTech
  • 362
  • 5
  • 4
1

Mac

Cmd+fn+F9

Windows

Ctrl+F9

Community
  • 1
  • 1
Jorge Casariego
  • 21,948
  • 6
  • 90
  • 97
0

Seems to be, in Android Studio Chipmunk 2021.2.1 at least:

  • 'File->Synchronize' refreshes project expolers Project view correctly
  • BUT it doesn't refresh the Android view. 'File->Invalidate caches and restart' refreshed this view for me. View is selectable from the drop down list up in the project explorer frame.