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:


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


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':

<img src="https://i.stack.imgur.com/iPdl1.png" alt="mobile+core in debug variant">


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

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.


  • Android Studio Error JUNIT4 !!! JUnit version 3.8 or later expected:
  • BuildConfig.VersionCode is not reflecting the actual versionCode after updating to AGP 3.2.0
  • Chart js - Draw center of each bubbles of a bubble chart
  • Product and product template in Odoo 10
  • Shopify API CARTS - Changing line_item line_price for price Override
  • Log4j cannot find properties file in a simple application
  • How to make SASS put relative paths in its output
  • Programmatically Update Linked Named Range of excel object in MS Word (2007)
  • Spring Integration Bridge with poller not working as expected for JMS
  • runtime error when linking ffmpeg libraries in qt creator
  • How to assert that an input element is empty in Ruby on Rails tests
  • Why cout is producing no output on Code Blocks?
  • C# Excel interop - how to test if interop object is still working and performing a task?
  • How to pass solution folder as parameter in command line arguments (for debug)?
  • Is it possible to run clang with llc flags
  • VSCode change debug shell to bash on windows
  • Why does java tzupdater add leap seconds?
  • Visual Studio 2010 debugger build correctly - compiler pdb and linker pdb not in synch?
  • Very simple C++ DLL that can be called from .net
  • Can I check if a recipient has an automatic reply before I send an email?
  • Getting last autonumber in access
  • RectangularRangeIndicator format like triangular using dojo
  • Cross-Platform Protobuf Serialization
  • Deserializing XML into class C#
  • Trying to switch camera back to front but getting exception
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Revoking OAuth Access Token Results in 404 Not Found
  • How to set the response of a form post action to a iframe source?
  • -fvisibility=hidden not passed by compiler for Debug builds
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • apache spark aggregate function using min value
  • python draw pie shapes with colour filled
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Sorting a 2D array using the second column C++
  • reshape alternating columns in less time and using less memory
  • How to Embed XSL into XML