I have a gradle script dynatrace.gradle, which contains some functions
apply plugin: 'com.dynatrace.instrumentation'
dynatrace {
configurations {
sampleConfig {
autoStart {
applicationId 'getApplicationId()'
beaconUrl 'getBeaconUrl()'
}
}
}
}
def getApplicationId(){
...
}
I want to call this getApplicationId() function from Kotlin class also. Is there any way to achieve this in Android application?
First, don't use dynatrace, use sentry.io (: (sorry, just kidding and showing off my bias)
On a serious note - you can't call build logic from within your source code. What you could do, however, is to use BuildConfig for that purpose, so adding something like this to your android config:
defaultConfig {
buildConfigField "String", 'APP_ID', getApplicationId()
}
// and use it like this in Kotlin
BuildConfig.APP_ID