Issue #109

People advise against storing keys inside build.gradles. We should store them on 1Password and populate our, so don’t track this file in git. Here is .gitignore file




There are several ways to help BuddyBuild know about our

1. Using Environment variables

But when configuring the project on BuddyBuild, it complains about key not found. The solution is to use Environment variables


Then in your build.gradle, you can

buildConfigField 'String', 'MY_KEY', System.getenv("MY_KEY") ?: MY_KEY

This is because gradle does not know about environment variables. The System.getenv("MY_KEY") is for BuddyBuild, and the default MY_KEY is for

Next is to remove this duplication. We can use Groovy Binding. build.gradle does the import import groovy.lang.Binding automatically for us

String environmentKey(variable) {
    for (Object var : binding.variables) {
        if (var.value == variable) {
            return System.getenv(var.key) ?: variable
    return ""
buildConfigField 'String', 'MY_KEY', environmentKey(MY_KEY)

2. Using Secured File 👍

BuddyBuild allows us to define Secured File, here we can upload our

secure files

And we can use Prebuild script to copy this secured file to our project. BuddyBuild suggests using but then build fails in Build file '/tmp/sandbox/workspace/app/build.gradle'

So, create a script called

#!/usr/bin/env bash