vendredi 5 mars 2021

Is it possible to put configuration outside of an Android package so that the exact same package can be used in test and prod?

My problem

I am building an Android application. Let's say that my application uses a backend API. I have two versions of the API:

https://test.api.mycompany.com/
https://prod.api.mycompany.com/

I would like to be able to create a package, test it and then promote the exact same package to the app store when it passes testing.

When building desktop or web applications, this can be achieved by putting your config in a separate file, so that in TEST environment, the app is pointing to test API and in PROD environment the app is pointing to the prod API.

Nice thing about this set up is: I can use the exact same executable in test environment, it is clear that just the config is different.

How can I achieve a similar setup with an Android application?

Things I considered

1. Build a separate package for production

Just forget about this problem, always product two packages, one pointing to test API, one pointing to prod API.

Downside: it is harder to prove that the tested version is the same as production version.

2. Default config and optional overrides

The app could go to https://prod.api.mycompany.com/ by default. If an override exists on the device (for example a local storage file) with a different API URL, the app would use that.

Downside: if there is a problem with the override, the test app would connect to production endpoints.

Aucun commentaire:

Enregistrer un commentaire