1

I have some keys or app_id, for instance, fabric app_id, in my build.gradle, different for different build like -

manifestPlaceholders = [
                    appIcon     : "@mipmap/kj_launcher",
                    roundappIcon: "@mipmap/kj_launcher",
                    fabric_id: "fabric_app_id"
            ]

which I indirectly use in AndroidManifest file.

So, my question is, a way to store that fabric_id inside any file which is present locally in my system and then load it over here in the above code, different for the different build?

Just like we do in .properties file and get the value from that inside build.gradle.

I don't want to expose these ids.

halfer
  • 19,824
  • 17
  • 99
  • 186
Aman Verma
  • 3,155
  • 7
  • 30
  • 60
  • Fetching system variables is common practice and should accomplish what you're looking for https://stackoverflow.com/questions/25589052/proper-way-to-use-system-environment-variables-in-gradle-using-android-studio/34640602 – em_ Jan 22 '19 at 16:04

1 Answers1

1

There's a number of ways to do this, but the way I do this is to define it the gradle.properties file.

In my local gradle.properties file:

MY_SECRET_API_KEY=Dev_Api_Key_That_I_Dont_Care_If_Devs_Have_Access_To

Then on my CI build server, I have a script that replaces Dev_Api_Key_That_I_Dont_Care_If_Devs_Have_Access_To with a value of the production API key.

SharpMobileCode
  • 938
  • 5
  • 8