Search code examples
androidcapacitorionic5

can I capture global variables in android, with ionic 5 capacitor?


I need to do a configuration, with android and iOS that when doing the deployment accepts the change, it is configured with firebase, which when I create a project and configure it, gives me a file google-services.json and in iOS a GoogleService-Info.plist, what I need is that for different environments, which are created in firebase, for example I would like to add the file google-service.json for the production environment, but if it is in staging, use the google settings- service-staging.json and so on.

So when you call the change in the project's build.gradle, pass it a global variable (I don't know if it can really be done)

def servicesJSON = file('google-services'+enviroment+'.json')

Something like this, so that depending on what comes to you, you know in what environment they are deploying...


Solution

  • For flavors (stage,prod) you should place separate json files in corresponding directories for android project.

    e.g. https://android.jlelse.eu/how-to-use-different-google-services-json-file-with-multiple-product-flavors-android-7853d98dd6c0