Search code examples
androidandroid-studiogradleintellij-ideacmake

How to stop Android Studio indexing parent folder of multiple subdirectories


I have an Android Studio Project that builds a native activity with C++, Gradle and CMake. The android project lives here src/myproject/myandroidproject.

The project lives in a large repository, that also contains a large folder (~50GB), src/thirdparty, full of thirdparty libraries.

The android project uses CMake and includes libraries from the src/thirdparty folder with add_subdirectory: add_subdirectory(../../thirdparty/mylibrary).

There's 5 total libraries that are used in the android project. I'm running into an issue when importing all of these with add_subdirectory that Android Studio will begin indexing the whole src/thirdparty folder, instead of each individual library folder. This causes Android Studio to completely freeze trying to index this massive folder.

I've noticed that if I only import up to 2 libraries from src/thirdparty that Android Studio indexes each individual library folder, and not the whole src/thirdparty folder. This is what I would like Android Studio to be indexing. However, when I try to include more than 2 libraries, Android Studio will then switch to trying to index the whole of src/thirdparty. I do not want this as it causes Android Studio to freeze.

I know that I can right click the src/thirdparty folder in Android Studio and mark the directory as excluded, but this seems like it needs to be done on every gradle sync, which is undesirable. I'm looking for a way to not have to do this every time I sync the project.

I have tried to use the gradle idea plugin, but am getting stuck working out how to try to exclude folders in a different directory tree than the one that the project is in.

Is there any way to get Android Studio to index each individual project instead of the whole src/thirdparty folder?


Solution

  • Referencing the real location of the other projects caused Android Studio to also index the sibiling directories when I was referencing more than 2 projects in the same directory.

    I instead switch to symlink-ing to the project locations from within my own project directory, which caused Android Studio to only index the projects I was trying to include.