Reputation: 43
I want to get VERSION_NAME from domain module. My config is in the main gradle (build.gradle (app)) and I don't know how to get this config. I try to get version name with:
package com.example.domain (domain)
val versionName = com.example.mainmodule.BuildConfig.VERSION_NAME
but BuildConfig is unresolved reference.
package com.example.mainmodule (app)
build.gradle(app)
productFlavors {
production {
applicationId "com.example.mainmodule"
versionCode 107
versionName '1.9.1'
}
}
Do I have to create any "dependencies.gradle" or something like that?
Upvotes: 4
Views: 12339
Reputation: 152787
You cannot have cyclic module dependencies. Your app module depends on the domain module so the domain module cannot depend on the app module and therefore cannot access its code.
In this case, you can obtain your app's version name via a Context
. See https://stackoverflow.com/a/6593822/101361
Upvotes: 6