Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove directories from Indexing in Android Studio?

I have a large project folder that contains many sub projects. Only 4 are part of the Android project, the rest are C code.

However, it appears that Android Studio is indexing ALL of it, which takes a long time.

How do I exclude these other directories from indexing?

There no way to explicitly do it, and the Module Settings only lists the Android projects so I cannot remove the other folders from there.

like image 640
gregm Avatar asked Nov 05 '14 21:11

gregm


People also ask

What is index in Android Studio?

android.arch.persistence.room.Index. Declares an index on an Entity. see: SQLite Index Documentation. Adding an index usually speeds up your select queries but will slow down other queries like insert or update. You should be careful when adding indices to ensure that this additional cost is worth the gain.


3 Answers

  1. Select the directory in the Project explorer.
  2. CtrlShiftA or ShiftCmdA
  3. Search for Excluded and hit enter.

Careful, I haven't been able to find a way to 're-include' folders back yet.

like image 110
Gautam Avatar answered Oct 03 '22 05:10

Gautam


  1. (optional) Switch to project view if you can't see the folders you want to exclude
  2. Right click the folder you want to exclude
  3. In the contextual menu click "Mark directory as" --> "Excluded"
    It should look like this: IDE contextual menu
  4. (optional) If you want to include a folder, click "Mark directory as" --> "Cancel exclusion" Other IDE contextual menu
like image 41
Tea Ghosty Avatar answered Oct 03 '22 06:10

Tea Ghosty


Use the 'idea' plugin to exclude directories. For some reason, it seems the idea configuration is ignored if a subproject is configuring it (and will always exclude the project.buildDir and .gradle folders), but it works if you tell the root project which directories to exclude:

In your root project build.gradle file, do

apply plugin: 'idea'
idea {
  module {
    excludeDirs.add(file('path/to/subproject'))
    excludeDirs.add(file('path/to/othersubproject'))
  }
}

After syncing, you'll notice that the root projects .iml file contains corresponding <excludeFolder> tags, and that Android Studio no longer indexes the directories.

like image 40
David Burström Avatar answered Oct 03 '22 07:10

David Burström