Puneet Verma
04/07/2023, 3:21 PMBuildConfig.java
file. But for a good reason I can’t access this file in the project. Could you please help me with this?
Thank you!Pablichjenkov
04/07/2023, 4:14 PMyshrsmz/BuildKonfig
on GitHub , see if good enoughMagdalena Tsolaki
04/07/2023, 4:14 PMbuildConfig {
val prefix = "CONST_CONFIG_";
useKotlinOutput { topLevelConstants = true }
useKotlinOutput { internalVisibility = false }
className("ConstConfig")
packageName("de.masterthesis.shared")
com.android.build.gradle.internal.cxx.configure.gradleLocalProperties(projectDir).filterKeys {
it.toString().contains(prefix)
}.map {
buildConfigField("String", it.key.toString().replace(prefix, ""), it.value.toString())
}
}
local.properties
CONST_CONFIG_DBFILE="task.db"
CONST_CONFIG_NINJAS_API_KEY="xxxx"
after build you can use “ConstConfig.DBFILE”Magdalena Tsolaki
04/07/2023, 4:16 PMPuneet Verma
04/10/2023, 4:33 AMbuildKonfig
library but it still lacks the support of accessing the variables defined in gradle.properties
or maybe I didn't explore it enough. I'll try that.
PS: I'm the same person.Pablichjenkov
04/10/2023, 4:40 AMPuneet Verma
04/10/2023, 4:46 AMgradle.properties
file as it's not included in the build and the variables are accessible in the build.gradle
file to utilise them in the buildConfigField()
method. But in KMM, I couldn't access those variables in the method.
For example:
gradle.properties:
apiKey="api_key_value"
build.gradle
...
buildConfigField("String", "SOME_API_KEY", apiKey)
...
Puneet Verma
04/10/2023, 4:48 AMapiKey
is not accessible in KMM.Pablichjenkov
04/10/2023, 6:00 AM