Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Multiple flavors



Hi. I have a project which has multiple versions, each one in a specific flavor.

We consider each flavor as a unique app, and we want to do it as well on new relic. The problem is that I haven’t found a way to set flavor specific tokens (since I have to create a file containing the token in the project’s root).

Is there a way to configure new relic with multiple tokens depending on the flavor?


The token value is specifically for crash reporting, and not the general performance monitoring data(Http requests, Interactions, Geo, etc).

Right now, there’s not a good way to set this token value for a specific productFlavor as defined in the build.gradle. I’ll make sure this gets added to our feature requests for the Android agent, because it really is a great suggestion, and an area we could improve on.


We are currently facing the same issue. A correct way is to use a newrelic.xml file in res folder. That way each flavour can override this xml file


We’ll certainly look into the options we have, and a newrelic.xml for overriding certainly seems like a good option.



Another option would be to create a gradle task to create the properties file every time a build is being made. But seems a little like an overkill. But a good workaround in the meantime though.


Thanks for that workaround, @nicolas_hormazabal!


Did something change in flavors support? Or we should stay with gradle ask for now?


Hi @mirek,
The process hasn’t changed. If gradle ask is working for you it would be best to stick with it for now


Would be great if someone can provide a working code solution to make this work in a clean way.
I am especially talking about the file, since the token for newrelic initialization is pretty straight forward.


@mit Just to clarify - you are using separate app tokens for each of the flavors in your app? If you use the same app token for each flavor of your app, there’s no need for any kind of custom logic.


I had to revive the topic since I’m having the same issue … Any updates on that?

I’m thinking to create a createPropertiesFile() task on Gradle’s build and make the build tasks depends on it … That way the API token will be part of the script and I don’t know if it’s the best solution …

If anyone have a more elegant way please share.

PS: I have two apps for my app created on the dashboard (debug and production), if also there’s a better way to do it please advice.



Hi @fduarte – There has been no change to our functionality yet, but we have recorded your feedback as a feature request.


Seems like the only workaround is to create gradle task to dynamically change
It’s my regret that NR does not support multiple flavor yet.


Hey @pingchenok - :frowning: I went ahead and submitted a feature request to support multiple flavors :slight_smile:


Well if anyone wants a workaround for now here it goes:

// Create New Relic properties file according to flavor
File newRelicProperties = new File("${project.projectDir.absolutePath}/")

android.applicationVariants.all { variant ->
    variant.productFlavors.each { flavor ->
        def variantSuffix =
        def generateResourcesTask = project.tasks.getByName("compile${variantSuffix}Sources")
        def generatePropertiesTask = task("newRelicGenerateProperties${variantSuffix}") << {
            Properties properties = new Properties()
            properties.setProperty("com.newrelic.application_token", flavor.ext.newRelicAppToken)
  , null)
        generateResourcesTask.dependsOn generatePropertiesTask

the ext.newRelicAppToken should be added to each flavor like this:

productFlavors {
    dev {
        ext.newRelicAppToken = "<dev-key>"

    qa {
        ext.newRelicAppToken = "<qa-key>"


Crash stack trace shows '-1' for app's line numbers, obfuscated method names
How to set up file for project with multiple build variants?
12/21/2015 Post of the WeeK: Multiple Flavors, Synthetics Scripts, and .NET DLLs!

@fduarte This is great. Thank you for sharing your work!


Thanks for sharing the code snippet. (y)


Any updates on this, should we use this workaround or ?


Will this ever be implemented by New Relic?