特定风味依赖

Joa*_*usa 6 android gradle android-gradle-plugin

我在为维度指定不同的依赖项debugrelease构建类型时遇到问题。

在我的app.gradle我指定1 维2 productFlavors,像这样:

android {

    [...]

    flavorDimensions "tier"
    productFlavors {
        free {
            dimension "tier"
        }
        paid {
            dimension "tier"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我想为所有构建变体(freeDebugfreeReleasepaidDebugpaidRelease)指定不同的依赖,我尝试这样做:

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";
}
Run Code Online (Sandbox Code Playgroud)

然而,这失败了

android {

    [...]

    flavorDimensions "tier"
    productFlavors {
        free {
            dimension "tier"
        }
        paid {
            dimension "tier"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

也许我以错误的方式接近这个要求。任何帮助将不胜感激。

PS 我正在使用3.1.2android gradle 插件版本4.7和 gradle 包装器版本。

Pet*_*ook 8

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
}
Run Code Online (Sandbox Code Playgroud)

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