amplify-android
amplify-android copied to clipboard
Configure amplifyconfiguration.json for development and Production
How to configure and maintain two different environment details for CognitoUserPool, awsCognitoAuthPlugin, CredentialsProvider and Auth information present in amplifyconfiguration.json android. Is there any way to achieve it using build variant or flavour etc.
Current these information are stored under res/raw/amplifyconfiguration.json
Amplify Android currently does not support developing under multiple environments. We can track this as a feature request and prioritize it depending on how much traction it receives.
it is possible to load the configuration file from different locations. We do this in our tests. You can select a config to load at runtime, and then use an alternate version of the configure method, which takes an explicit configuration object:
@RawRes val resourceId = if (BuildConfig.DEBUG) R.raw.debugConfig else R.raw.releaseConfig
val config = AmplifyConfiguration.fromConfigFile(applicationContext, resourceId)
Amplify.configure(config, applicationContext)
h/t to @jamesonwilliams who shared this approach in Discord.
I'm going to leave this open as a feature request though, because I think we could come up with a more streamlined approach that doesn't require manually creating config files, and trying to keep them up to date with the generated one.
Is there any update on this?
Any update on this since v2?
Hello, We have different build flavors for development and production environment. To achieve this, we stored the file under the specific path for each build flavor:
- production: src/main/res/raw/amplifyconfiguration.json
- development: src/dev/res/raw/amplifyconfiguration.json
Olá, Temos diferentes tipos de construção para ambiente de desenvolvimento e produção. Para conseguir isso, armazenamos o arquivo no caminho específico para cada tipo de compilação:
- produção: src/main/res/raw/amplifyconfiguration.json
- desenvolvimento: src/dev/res/raw/amplifyconfiguration.json
I tested it here and it worked, thanks for the help