Android Studio : Exclude files in build folder from search result

后端 未结 6 2589
忘掉有多难
忘掉有多难 2020-12-13 05:34

I have an Android Studio project in which I have multiple modules, each of those module depending on a share module. And let\'s say that this share module has an xml file ca

相关标签:
6条回答
  • 2020-12-13 06:07

    Had the same issue. Found that these 'build' folders were marked as sourceFolder in the module's .iml file.

    Removing all such entries fixed the problem

    <sourceFolder url="file://$MODULE_DIR$/build/..." ..../>
    
    0 讨论(0)
  • 2020-12-13 06:10

    To put it simply, and to actually exclude build paths from your search, you need to follow Frank's answer point 1 and 2, then because there's no suitable scope that actually exclude the build folder, simply do this:

    Starting from the Find in Path dialog,

    1) Tap the ... to configure a scope
    2) Click the + and give your new scope a name
    3) Enter "!file:build//*" in the pattern without the double quotes
    4) Tap ok and use your new scope
    

    If you further want to have a scope for a single module, create a scope for your module (including recursively your module path), then add this at the beginning of your pattern:

    !file:build//*&&
    

    For example, a scope for 2 modules:

    !file:build//*&&file[MODULE1_DIRECTORY_NAME]:*/||file[MODULE2_DIRECTORY_NAME]:*/
    

    Only got the full answer reading Frank's answer and post #7 from issue reported here: http://code.google.com/p/android/issues/detail?id=61488

    0 讨论(0)
  • 2020-12-13 06:10

    To exclude all build folders from all modules use this pattern:

    !file:*build*/
    

    If you want exclude also all libraries, simply use this pattern:

    !file:*build*/&&!lib:*..*
    

    Detailed description:

    1. In the Find window click on the Scope tab, then on three dots button:

    1. Plus button -> Local -> Enter name

    1. Add the desired pattern:

    1. Save and enjoy!
    0 讨论(0)
  • 2020-12-13 06:18

    Android Studio -> Appearance & Behavior -> Scopes -> + -> add scope -> local -> set a custom name & set Pattern

    !file:*intermediates*/&&!file:*generated*/&&!file:R.java

    0 讨论(0)
  • 2020-12-13 06:21

    You can create a Custom Scope which defines the set files that you want to search and allows you to exclude those that you do not want to search.

    1. CTRL+SHIFT+F to present the Find in Path dialog.
    2. Under Scope select Custom
    3. If one of the Scopes that are present in the drop down list does not restrict the file search according to your needs you can create your own Custom Scope. To do this click on the ... button.
    4. Then Click on the + button and select Local
    5. In the pane on the right you can Include and Exclude individual files and Recursively include or exclude all files beneath a folder.

    You can then use your Custom Scope to constrain the files that are searched when you do Find in Path.

    0 讨论(0)
  • 2020-12-13 06:23

    This problem seems to be fixed in later versions of Android Studio, but should it reoccur or you have a special folder setup:

    You need to modify the exclusion list through gradle with the help of the idea plugin

    Example:

    apply plugin: 'idea'
    
    idea.module {
        excludeDirs += file('build/')
    }
    

    Then run task ideaModule to regenerate the .iml file with the exclusion line described in Corwin's answer

    0 讨论(0)
提交回复
热议问题