Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine variant and build type in dependency implementation

I need to implement variant-specific libraries im my project, lets say i have:

flavorDimensions "dimensionOne", "dimensionTwo"

productFlavors {
    dimensionOneVariantOne {
        dimension "dimensionOne"
    }
    dimensionOneVariantTwo {
        dimension "dimensionOne"
    }
    dimensionTwoVariantOne {
        dimension "dimensionTwo"
    }
    dimensionTwoVariantTwo {
        dimension "dimensionTwo"
    }
}

and in dependency implementation, i need to use, for example

dimensionTwoVariantOneDebugImplementation("maven-library:version")
dimensionTwoVariantOneReleaseImplementation("maven-library:version")

I thought that was the correct syntax, but somewhy I'm not able to do that, I get a "Could not find method dimensionTwoVariantOneDebugImplementation() for arguments " error.

I defined two flavorDimensions because thats what I have in my real project, and the first one is not relevant for the implementation on that library. But I also tried including it with no success

like image 541
Lucas Meneghin Avatar asked Feb 03 '26 19:02

Lucas Meneghin


1 Answers

@Edit

Adding only one configuration wasn't enough, I had to add the full combinations in both configuration and dependency implementation, like

configurations{
  dimensionOneVariantOneDimensionTwoVariantOneDebugImplementation
  dimensionOneVariantOneDimensionTwoVariantOneReleaseImplementation
  dimensionOneVariantTwoDimensionTwoVariantOneDebugImplementation
  dimensionOneVariantTwoDimensionTwoVariantOneReleaseImplementation
}

and the respective implementation blocks


Apparently, all i needed was

configurations{
    dimensionTwoVariantOneDebugImplementation
}

I'm not sure tho if not adding the other variants will have any impact

like image 130
Lucas Meneghin Avatar answered Feb 05 '26 07:02

Lucas Meneghin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!