I'm trying to implement an `AttributeDisambiguatio...
# community-support
t
I'm trying to implement an
AttributeDisambiguationRule
. I'm getting an illegal argument exception:
Copy code
Unable to determine constructor argument #1: missing parameter of type ObjectFactory, or no service of type ObjectFactory.
(note in case anyone wonders: this is the
org.gradle.api.model.ObjectFactory
) Here's a simplified version that includes just the relevant details:
Copy code
// plugin class
attribute(BuildTypeAttr.ATTRIBUTE).run {
  disambiguationRules.add(AndroidBuildTypeDisambiguationRule::class.java)
}

// separate class
abstract class AndroidBuildTypeDisambiguationRule @Inject constructor(
  private val objects: ObjectFactory,
) : AttributeDisambiguationRule<BuildTypeAttr> {
  override fun execute(details: MultipleCandidatesDetails<BuildTy
    val release = objects.named(BuildTypeAttr::class.java, "release")
  }
}
When I run this, it fails with:
Copy code
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':platform:generateMetadataFileForPlatformPublication' (registered by plugin 'org.gradle.maven-publish').
> Could not resolve project ':producer-android'.
   > Could not select value from candidates [debug, release] using AndroidBuildTypeDisambiguationRule.
      > Could not create an instance of type com.autonomousapps.platformbuilder.internal.utils.attributes.AndroidBuildTypeDisambiguationRule.
         > Unable to determine constructor argument #1: missing parameter of type ObjectFactory, or no service of type ObjectFactory.
My code looks like an exact replicate of the example in the Gradle docs here. What am I doing wrong?
❓ 1