Is there a way to hide empty sourceSets in Android Studio

210 Views Asked by At

I'm writing a Kotlin Multiplatform project in Android Studio. As a result, I have multiple sourceSets configured in the project but some of them are empty. Removing them from the Gradle build is not possible as they are required for building the project. Is there a way to hide them from being displayed by the IDE?

(Android Studio Dolphin | 2021.3.1 Patch 1)

enter image description here

3

There are 3 best solutions below

2
On

Click the dropdown at the top labeled "Android" and select the "Project" view instead. This will display only the directories that are actually present on the filesystem rather than showing every source set that's configured.

1
On

There is no built-in way to hide empty source sets, but you can create a custom annotation to do this.

Here is the Example. I Hope It would help you.

@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class HideEmptySourceSet

For more details about annotations check this link:

https://kotlinlang.org/docs/annotations.html

0
On

Unfortunately there is no such option built-in in Android Studio environment.

It's also possible to use a different view (e.g. Project) or define bookmarks and favourites to navigate around quickly.

I would advise to try out the favourites, as setting up will take about 3 minutes and will make it way more comfortable to use.