简体   繁体   English

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

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

I have a 'mobile' module that depends on a 'core' module, and I keep getting the same inconsistent error: 我有一个依赖于“核心”模块的“移动”模块,并且不断收到相同的不一致错误:

mobile/build.gradle: 移动/的build.gradle:

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

core/build.gradle: 核心/的build.gradle:

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

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

Whenever I set my variants to be mobile debug + core debug, I still get the same output inside my core.MyApplication.java file: ' https://core.release ': 每当我将变体设置为移动调试+核心调试时,我的core.MyApplication.java文件中仍会得到相同的输出:' https://core.release ':

调试版本中的mobile + core

Whenever your modules imports another dependency-module, the dependency-module uses it's 'release' variant. 每当您的模块导入另一个依赖模块时,依赖模块都会使用其“发布”变体。

See: BuildConfig.DEBUG always false when building library projects with gradle 请参阅: 使用gradle构建库项目时,BuildConfig.DEBUG始终为false

The solution for this is to use your com.main.module.BuildConfig.DEBUG variables, and not your com.dependency-module.BuildConfig.DEBUG...cause this debug will always be 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