Sounds like you need to split things into three libraries, x, y and z.
Either way, I guess it would be nice to “leave out” selected elements of a library when including it, or at least from the final build.
You could easily create a project with multiple subprojects in Gradle. So, create 3 sub-projects: X, Y and Z and publish them to your local (or remote repository). Then the apps could grab what they need.
We prefer keeping things as simple as possible at the moment - granularity in “who can use what parts”, disabling things in UI etc is going to complicate things exponentially, and will likely not happen in the forseable future. Some smart build-features to “ignore/skip” files from being included in the app is a much better solution imho.
Does not solve it, but it’s better to split up in different subprojects (artifacts) and have the artifacts stable and not changing depending on the “build”-environment.
So, if you need libs, then you are thinking reusability. Then you will need to construct your libs so that the libs is the smallest pieces to build your application with.
My suggestion then is to create a lib for each X, Y and Z.