如何根据buildTypes选择不同的aar

问题描述 投票:0回答:1

我有一个使用 aar 库的 Android 应用程序。该库存储在

libs
文件夹中。它工作正常,但是我找到了该库的调试版本,因此我希望能够在库之间进行选择。所以我首先定义了如下的库:

publishing {
    publications {
        libLogLatest(MavenPublication) {
            groupId 'com-log'
            artifactId 'libLog'
            version '0.1.0'
            artifact("$libsDirName/libLog_0_1_0.aar")
        }
        libLogDbg(MavenPublication) {
            groupId 'com-log'
            artifactId 'libLogDbg'
            version '0.1.0'
            artifact("$libsDirName/libLog_0_1_0_Int.aar")
        }
    }
}

然后我将其加载到依赖项部分:

dependencies {
    implementation "com-log:libLog:0.1.0"
    //implementation "com-log:libLogDbg:0.1.0"
}

有没有办法使用 buildType 自动在

libLog
libLogDbg
之间进行选择?

谢谢

android kotlin gradle gradle-dependencies
1个回答
0
投票

我们在应用程序模块的

dependencies
块中有这样的配置,如下所示:

    DebugImplementation(files('libs/library-debug.aar'))
    ReleaseImplementation(files('libs/library-release.aar'))
© www.soinside.com 2019 - 2024. All rights reserved.