Hi i have an android gradle build issue i cannot f...
# general
t
Hi i have an android gradle build issue i cannot find a solution for...
🔮 4
😂 1
my application employs NewRelic for crash reporting etc. we have two newrelic entries for our current application one for Production the other for our qa environment new relic requires a token to be placed in a simple file at a specific location.... namely the
mobile-android/app/newrelic.properties
how can i employ gradle to create this file in the correct location with the required environment token?
r
I think that you need to share much more details, which plugins do you use, which error do you get etc… who should create that properties file for you?
n
Is new relic a tool that you pay for? Perhaps it would be best to get in contact with their support team regarding this.
1
t
i have no idea where to start 🤦 for android "flavours" gradle supports a very simple configuration approach as shown here
productFlavors {
development {
dimension "default"
buildConfigField 'String', 'NEW_RELIC_TOKEN', '"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-YYYYY"'
}
staging {
dimension "default"
buildConfigField 'String', 'NEW_RELIC_TOKEN', '"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ-YYYYY"'
}
production {
dimension "default"
buildConfigField 'String', 'NEW_RELIC_TOKEN', '"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH-YYYYY"'
}
}
when i build for either of the three defined "flavours" the correct token is used however I also need to use the correct token in the flat file documented above does gradle support dynamically populating a file or dynamically creating a file within my project structure
based on t he chosen "flavour"
r
I don’t know relic, when you did not write that code (gradle file) ask that person who did it. otherwise check their documentation or ask the support.
t
surely its not related to new relic? all i need to know is if gradle will allow me to create a file or write to an existing file? 🤔
r
basically you can do whatever you want with gradle
you can write a simple task to write “hello world” to any file within a couple of minutes. just google for gradle greeting task
👍 1
v
That's pretty easy generally. You have the file
mobile-android/app/newrelic.properties
in
src/main/resources
with a placeholder for the value, then you configure the
processResources
task to
filter
the file content where one filter is to replace such placeholders. I just don't know how it is with Android in the play, whether you can configure the task according to the flavor, or whether there are different tasks or whatever as I don't do any Android.
👍 1
r
Working with flavors dynamically is quiet complex, however it took me 3 days to get this implemented in a custom plugin