It is really irritating. I need more time to find some class because of dagger 2.

- 60,783
- 13
- 169
- 249

- 9,562
- 7
- 42
- 55
-
1Which search are you talking about? `Command + Shift + O`? If yes, than it's "search everywhere", it should bring everything. – azizbekian Jul 21 '17 at 12:09
4 Answers
If you are talking about the generated MembersInjector
and Factory
classes:
MyClass_MembersInjector.java
MyClass_Factory.java
you can prevent these from coming up in the Ctr-N or Cmd-O dialog by adding them to the ignored files list in File / Settings / Editor / FileTypes
and adding the appropriate wildcards to the Ignore files and folders
edittext:
*_MembersInjector.java; *_Factory.java;
will cause most of the generated classes to be ignored:
Before:
After:
You can even add Dagger*.java
to the list if you don't even want to see the generated component (even though this is rather useful for the project).
Update:
If you are talking about not having the classes appear in auto-import/auto-complete this is done through Settings / Editor / General / Auto Import
:

- 20,912
- 7
- 88
- 124
-
4As for 2020 year Dagger 2, you change exceptions line to _Provide.java;*_Factory.java;*_Bind*.java – Dmitriy Pavlukhin Oct 16 '20 at 11:00
-
@DmitriyPavlukhin Yes `_Provide.java;*_Factory.java;*_Bind*.java` worked thanks for the update – Shailendra Madda Nov 02 '20 at 12:01
-
2For [Hilt](https://dagger.dev/hilt/) I use these exceptions: `*_MembersInjector.java; *_Factory.java; *_Providers.java; *_Bindings.java; *_HiltComponents_*.java` – Sven Jacobs Sep 09 '21 at 06:25
-
nice! I've added to this rules suggestions from the https://aednlaxer.medium.com/getting-rid-of-generated-files-in-search-dialog-in-android-studio-ae466a1261a4 – Kirill Vashilo Jun 01 '23 at 12:13
David Rawson's answer doesn't help to get rid of not showing _Factory
classes when performing Find Usages
on the class name. This is what will be shown:
This can be resolved with creating a new scope which will disregard generated files.
Here's the regex for generated files in app
module: !file[app]:build/generated//*
. But you may as well use "Exclude recursively" button locating the directory you want to get rid of.
Now, change the search scope to newly created:
And this will be the output:
No _Factory
classes. You may as well get rid of classes in test packages, thus only classes from production package will be found.

- 60,783
- 13
- 169
- 249
-
5That's great. I would even write it as !file:build/generated//* that way it'll remove generated from other modules than app – usernotnull Nov 07 '18 at 06:39
-
How can we filter if it's for instance: Hilt_LoginActivity? It's a generated file from Hilt. Thank you. – Red M Apr 22 '21 at 21:31
-
In Android Studio Dolphin there is a new option in Find Usages
dialog, so you can ignore usages in generated code.

- 10,153
- 3
- 45
- 56
In Android Studio, go to
File -> Settings -> Editor -> File Types -> Ignored Files and Folders
and add wild cards. Enter apply.
For Hilt, you can add following flags/wildcards *_MembersInjector.java; *_Factory.java; *_Providers.java; *_Bindings.java; *_HiltComponents_*.java; *_Provide*.java

- 21
- 3