5

One of the most productive actions in Android Studio is Navigate action. The problem is it shows so much useless files. Sometimes it's hard to find the class/file you're looking for.

Take below image as an example. If you're looking for AndroidManifest.xml in module b you have to scroll down the list to find the file you want.

enter image description here

Is there a way to filter what this dialog shows, in particular exclude some directories from results? All of the files from the /build directory are completely useless.

I know that I can filter what types of files are shown but it doesn't help much.

tomrozb
  • 25,773
  • 31
  • 101
  • 122

1 Answers1

2

Mark your build folder as excluded:

File > Project Settings > Modules > Sources > Mark as Excluded (red icon)

Alternatively, right click on your build folder and select Mark Directory as > Excluded.

Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores". Very limited coding assistance is provided for files in excluded folders. Classes contained in excluded folders don't appear in code completion suggestion lists, references to such classes are shown in the editor as unresolved. When searching, IntelliJ IDEA doesn't look in excluded folders, etc.

Source

Another way is to define a custom scope as described here.

Community
  • 1
  • 1
Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • This also excludes `R.java` files so imports in other classes show that R class cannot be resolved. It indeed solved the problem with navigation action but causes other problems, therefore I cannot accept this answer. – tomrozb Apr 25 '15 at 12:15
  • Then you need to define a custom scope: http://stackoverflow.com/a/29049768/1116549 – Darek Kay Apr 25 '15 at 12:56
  • 5
    You cannot use scopes in Navigate > Class or File action. Scopes are related to Find action not Navigate as far as I know. – tomrozb Apr 25 '15 at 16:38
  • I am resorting to using my build tool to exclude certain redundant (to me) directories to avoid opening the wrong class files. This reduces build times slightly but still is a time tax overall. – davidjmcclelland Feb 19 '18 at 15:54
  • 2
    There is no `Sources` tab under Modules for Android Studio. – beyondtheteal Oct 17 '19 at 15:07