Skip to content

Instantly share code, notes, and snippets.

@AlexKorovyansky
Last active March 9, 2021 15:54
Show Gist options
  • Save AlexKorovyansky/9da560b3aba25fdb0ce3 to your computer and use it in GitHub Desktop.
Save AlexKorovyansky/9da560b3aba25fdb0ce3 to your computer and use it in GitHub Desktop.
Trick for separating Develop from Release versions in New Relic Mobile SDK.
...
android.applicationVariants.all { variant ->
task ("prepareNewRelicProperties${variant.name.capitalize()}"){
doLast {
copy {
from variant.buildType.debuggable ? "${project.projectDir}/src/debug" : "${project.projectDir}/src/release"
into "${project.projectDir}"
include "newrelic.properties.*"
rename "newrelic.properties.*", "newrelic.properties"
}
}
}
tasks.getByName("prepare${variant.name.capitalize()}Dependencies").dependsOn("prepareNewRelicProperties${variant.name.capitalize()}")
}
# should be located in src/debug
com.newrelic.application_token=MyNewRelicDebugApplicationToken
# should be located in src/release
com.newrelic.application_token=MyNewRelicReleaseApplicationToken
...
NewRelic.withApplicationToken(getString(R.string.my_new_relic_application_token).start(this);
...
<!--should be located in src/debug/res/values-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="my_new_relic_application_token">MyNewRelicDebugApplicationToken</string>
</resources>
<!--should be located in src/release/res/values-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="my_new_relic_application_token">MyNewRelicReleaseApplicationToken</string>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment