Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

specific flavor dependency

I'm having issues specifying different dependencies for debug and release build types combined with dimensions.

In my app.gradle I specified 1 dimension and 2 productFlavors, like so:

android {

    [...]

    flavorDimensions "tier"
    productFlavors {
        free {
            dimension "tier"
        }
        paid {
            dimension "tier"
        }
    }
}

Now I want to specify different dependencies for all the build variants (freeDebug, freeRelease, paidDebug, paidRelease), and I tried doing it like so:

dependencies {
    freeDebugImplementation "com.someDependency:free-debug:1.0.0";
    paidDebugImplementation "com.someDependency:paid-debug:1.0.0";

    freeReleaseImplementation "com.someDependency:free-release:1.0.0";
    paidReleaseImplementation "com.someDependency:paid-release:1.0.0";
}

However, this fails with

Could not find method freeDebugImplementation() for arguments [com.someDependency:free-debug:1.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Maybe I'm approaching this requirement the wrong way. Any help will be greatly appreciated.

P.S I'm using version 3.1.2 of the android gradle plugin, and version 4.7 of the gradle wrapper.

like image 454
Joao Sousa Avatar asked Apr 26 '18 13:04

Joao Sousa


1 Answers

This section of the Android Studio manual indicates that you need to explicitly declare variant configurations before you use them, i.e. with this:

configurations {
    freeDebugImplementation
    paidDebugImplementation
    freeReleaseImplementation
    paidReleaseImplementation
}

I don't know whether that's still the case, but worth a shot.

like image 82
Peter Ledbrook Avatar answered Oct 21 '22 08:10

Peter Ledbrook