Search Everywhere not working fine in Android Studio 3
Asked Answered
E

4

20

Search Everywhere is not working fine in Android Studio 3. When I type anything, it doesn't show up. Take a look at screenshot below, typed AndroidManifest but no result.

If I look for any layout file, it shows file reference in R.layout file.

Searching for a layout file and getting results from R file.

Searching for AndroidManifest and its asking to create a new file :/

EDIT:

Ctrl + Shift + N doesn't work as well.

enter image description here

Tried restarting AS but no luck.

Elevated answered 6/11, 2017 at 10:54 Comment(2)
Can't reproduce using AS 3.0Hydrotropism
Ctrl + Shift + N doesn't work as well. dropbox.com/s/l4q5e0lteya9m7m/…Elevated
S
35

Go to File -> Invalidate Caches / Restart...

Once you have restarted the search index will be rebuilt.

Schneider answered 7/11, 2017 at 14:4 Comment(4)
Working fine for meJustification
This "solution" is unacceptable! How do you know that you have to do this? Do you do this EVERY TIME YOU DO A SEARCH? I'm going back to using grep--at least it won't give false results.Colloid
@Colloid in the last 5 years of using Android Studio daily I've had to do this maybe twice to rebuild the search index. Your solution below using grep is not an adequate replacement for the search everywhere functionality and doesn't address the OP's question. Perhaps you should file an issue on the Android Studio bug tracker if you are seeing this frequently?Schneider
@VictorRendina Not a bad idea. I'll add it to their bugs, thanks for the suggestion.Colloid
C
2

Search in Android Studio is not reliable. Since so much programming really needs searching to work and work EVERY TIME (and since invalidating caches and restarting is NOT AN OPTION for each time you need to search) I have the following old-school but reliable solution:

grep

Make sure your working directory is the base directory of your project. Type:

grep -r 'pattern' .

  • To make it case insensitive, add "-i" to the command.
  • You can add a file pattern with "--include [file_pattern]", such as --include "*.java" or --include "*.xml" to speed things up.
  • You can pipe the results into a file or the less command, where you can then search the search results, ;)

And the best part? It Works!

Colloid answered 7/2, 2021 at 3:50 Comment(4)
Ok... but it still doesn't take me straight to the result, right? 😏 Coz often when I search everywhere, I KNOW where the code is!... I'm just too lazy to manually navigate to it...Haff
Hehe. Grep won't take you to the code, but it will tell you the file, file location, and the line number. The rest is up to you, unless your editor/IDE can understand grep (and some do I think).Colloid
Oh, darnit... Well, invalidate caches and restart seems to have done it, anyway. 😏 But as you say, that adds a lot of time to your project! (I'm using Android Studio - do you know if it "understands grep" somehow?)Haff
Not really something I've played with much. But View->Tool Windows->Terminal (or alt-F12) will get you a nice command line window which should make things a little easier.Colloid
J
2

For me it works neither. The search everywhere function is broken for me, at least, it does not search everywhere (no full text search). I can literally paste a line of code of a file open in android studio, into the search everywhere box and it does not return the file that is open in front of me.

The find in files (ctrl + shift + f) function searches text / source files for the string and gives the expected result.

Jestude answered 24/5, 2022 at 21:43 Comment(0)
B
0

Search Everywhere shows "Recent Files" if the files have not been opened recently then they will not show up in search. Open all your files (you can open 10 at a time by selecting and pressing Enter key) and close all. This will index them all in recent files and then you can use search everywhere.

Not sure how time is calculated for "Recency".

A better way to search for file is go to Navigate->File (by this way you can search for any file). You can note the shortcut written next to it (depending on if you are using Mac or Windows).

Brownedoff answered 12/1, 2019 at 1:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.