Included build only for debug configuration

Our Android project is using the standard debug and release configurations.

What we’d like to achieve is that if the build is started using assembleDebug then the included build is used. Otherwise if the build is started using assembleRelease then dependency from maven artifact is used.

In Gradle’s docs is a sample how to achieve this, but it is not working. As in if the includedBuild is not commented out Gradle will still use it instead of the Maven artifact when doing an assembleRelease.
Gradle doc link:
https://docs.gradle.org/current/userguide/composite_builds.html#deactivate_included_build_substitutions

Code snippets:

SETTINGS.GRADLE
  // Foo modules
    includeBuild("foo.bardevkit.android")

BUILD.GRADLE
 configurations.releaseImplementation{
        resolutionStrategy.useGlobalDependencySubstitutionRules.set(false)
        isCanBeConsumed = false
        isCanBeResolved = true
        attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
}

dependencies {
    releaseImplementation("com.foo.sdk:foo-sdk:${libs.versions.sdkVersionName.get()}-SNAPSHOT")
    debugImplementation(project(":foo-sdk"))
...
}

I’m not familiar with Android builds.
But are you sure you deactivated the substitution on the correct configuration?
Afair this setting is not transitive.
So if the build uses a configuration that extends releaseImplementation then it will still use the included build.

@Vampire
I’ve also tried changing all configurations and it still does not work:

configurations.forEach {
    it.apply {
        resolutionStrategy.useGlobalDependencySubstitutionRules.set(false)
        isCanBeConsumed = false
        isCanBeResolved = true
        attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
    }
}

That only catches all configurations already existing. Instead use configurations.all.

Thank you @Vampire for the all advice, it helped narrow the issue down. I needed to use the releaseRuntimeClasspath. Now it works.