繁体   English   中英

如何更改库依赖模块的构建变体?

[英]How do I change the build variant for a library dependency module?

我有一个依赖于“核心”模块的“移动”模块,并且不断收到相同的不一致错误:

移动/的build.gradle:

    debug {
        buildConfigField "String", "URL_SEARCH", "\"https://mobile.debug\""
    }
    release {
        buildConfigField "String", "URL_SEARCH", "\"https://mobile.release\""
    }

核心/的build.gradle:

    debug {
        buildConfigField "String", "URL_SEARCH", "\"https://core.debug\""
    }

    release {
        buildConfigField "String", "URL_SEARCH", "\"https://core.release\""
    }

每当我将变体设置为移动调试+核心调试时,我的core.MyApplication.java文件中仍会得到相同的输出:' https://core.release ':

调试版本中的mobile + core

每当您的模块导入另一个依赖模块时,依赖模块都会使用其“发布”变体。

请参阅: 使用gradle构建库项目时,BuildConfig.DEBUG始终为false

解决方案是使用com.main.module.BuildConfig.DEBUG变量,而不是com.dependency-module.BuildConfig.DEBUG ...,因为此调试将始终为false。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM