I'm building an application that uses an Android library as the primary source of code. Then I have multiple apps using that library; these apps will have the same code, but different configuration fields, such as endpoints and so.
To accomplish this, I thought I could have a buildConfigField
in my library's build.gradle
file, and then override that value in my app's build.gradle
by using the same name, like this:
build.gradle in library:
buildConfigField "String", "API_BASE_URL", "\"http://arandomapibaseurl.com\""
build.gradle in app:
buildConfigField "String", "API_BASE_URL", "\"http://myrealapi.com\""
Any ideas on how to accomplish this?
Thanks!
BuildConfig
classes, one for your library's package and one for your app's package. Your library knows nothing about the app'sBuildConfig
, and I'm not aware of a way for an app to override theBuildConfig
from the library. You might need to explore other options (e.g.,<meta-data>
manifest elements pointing to XML resources, ordinary Java-based configuration, overriding assets).