AouledIssa
AouledIssa

Reputation: 2824

How to add source set to android project

In my android project I want to add an additional sourceSet aside with the default android source sets (main, debug...)

In my build.gradle file I have tried the following:

android {
...
    sourceSet {
        create("shuttle")
    }
....
}

unfortunately I get this error when I sync/build the project ERROR: The SourceSet 'shuttle' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?

Any ideas how to create android source sets that will appear under src/{sourceSetName} directory like the way I see src/main?

Thanks.

Upvotes: 3

Views: 2430

Answers (1)

Leon S.
Leon S.

Reputation: 3686

Android does not allow you to define custom sourcesets anymore. The default sourcesets are: main, debug and release and if you really want another one, you could add a buildtype or a flavor for which android then creates an accompanying sourceset.
Also see my other answer: https://stackoverflow.com/a/73231777/3968618
And someone else's example: https://stackoverflow.com/a/61810433/3968618

Upvotes: 3

Related Questions