Anton Popov
1 min readNov 13, 2022

--

Thank you for the question!

I thought that only buildTypes support custom source sets. After reading your comment I fully read this doc https://developer.android.com/studio/build/build-variants and realized, that not only productFlavors, but also productFlavor + buildType = buildVariant combinations support custom source sets 🤯.

However, even if I had known about this AGP feature, I think I would not have used it, because I work on an existing project where 4 buildTypes were already set up. Adding productFlavors would require modifying bash scripts for publishing final apks, CI setup and other stuff.

On your second point, I think (though I haven’t tested this) even if you use initWith, name of the custom buildType will still be different (not debug or release), and it is used in gradle’s variant aware matching.

So this code won’t work:

dependencies {
alphaImplementation(Libraries.showkase)
}

Maybe using initWith causes dependencies to be copied to the new buildType, but again, I haven’t tested this. If this assumption is true, using initWith would indeed solve the problem:

dependencies {
// dependency will be copied to alpha buildType as well
debugImplementation(Libraries.showkase)
}

The more you live, the more you learn) 🧠

--

--

Anton Popov
Anton Popov

Written by Anton Popov

Android Developer who ❤️ Jetpack Compose

Responses (1)